diff options
author | Dylan William Hardison <dylan@hardison.net> | 2018-04-01 16:52:36 +0200 |
---|---|---|
committer | Dylan William Hardison <dylan@hardison.net> | 2018-04-01 16:52:36 +0200 |
commit | ab229b9a828b77f8a3b9ce215f0dfed4c84d4ae5 (patch) | |
tree | 483da9c8b66f4444bb8a410e3d599c7484ad721e /.circleci | |
parent | daa2d6b1c40354ecce0e48e6c5ee686efe642c4b (diff) | |
parent | 2f8b999750cc700faf03c6aee1c53d1fc4df767f (diff) | |
download | bugzilla-ab229b9a828b77f8a3b9ce215f0dfed4c84d4ae5.tar.gz bugzilla-ab229b9a828b77f8a3b9ce215f0dfed4c84d4ae5.tar.xz |
Merge branch 'master' into unstable
Diffstat (limited to '.circleci')
-rw-r--r-- | .circleci/config.yml | 147 |
1 files changed, 112 insertions, 35 deletions
diff --git a/.circleci/config.yml b/.circleci/config.yml index 3ed28133d..eca472ceb 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -11,8 +11,6 @@ main_filters: &main_filters - /^(?:release|test)-20\d\d\d\d\d\d\.\d+/ - /\// - production - tags: - only: /^(?:release|test)-20\d\d\d\d\d\d\.\d+/ defaults: bmo_slim_image: &bmo_slim_image @@ -63,12 +61,61 @@ defaults: run: name: default qa setup command: | + [[ -f build_info/only_version_changed.txt ]] && exit 0 mv /opt/bmo/local /app/local perl -MSys::Hostname -i -pE 's/bmo.test/hostname() . ":$ENV{PORT}"/ges' $BZ_QA_CONF_FILE - /app/scripts/entrypoint.pl checksetup_gen_files --default-localconfig + /app/scripts/entrypoint.pl checksetup_gen_files --default-localconfig mkdir artifacts jobs: + build_info: + parallelism: 1 + working_directory: /app + docker: + - <<: *bmo_slim_image + environment: + <<: *bmo_env + steps: + - checkout + - run: + name: build push data + command: | + mv /opt/bmo/local /app/local + perl checksetup.pl --no-database --no-templates --no-permissions + perl scripts/build-bmo-push-data.pl + - run: + name: only publish if tag exists + command: | + tag="$(cat build_info/tag.txt)" + git fetch --tags + if git tag | fgrep -q "$tag"; then + echo "tag $tag exists!" + else + echo "tag $tag does not exist" + echo yes > build_info/publish.txt + fi + - run: + name: check if only version changed + command: | + if git diff 'HEAD~..HEAD' --name-only | grep -qv '^Bugzilla.pm'; then + echo "more files than just Bugzilla.pm changed." + exit 0 + fi + if git diff 'HEAD~..HEAD' |grep '^[+-][^+-]' | grep -qv '^[+-]our $VERSION'; then + echo "Something other than the version number changed." + exit 0 + fi + if [[ "$CIRCLE_BRANCH" == "master" ]]; then + echo "Can't cut corners on the master branch" + exit 0 + fi + echo yes > build_info/only_version_changed.txt + - persist_to_workspace: + root: /app/build_info + paths: ["*.txt"] + - store_artifacts: + path: /app/build_info + build: working_directory: /app docker: @@ -85,39 +132,52 @@ jobs: --build-arg CIRCLE_SHA1="$CIRCLE_SHA1" \ --build-arg CIRCLE_BUILD_URL="$CIRCLE_BUILD_URL" \ -t bmo . + - attach_workspace: + at: /app/build_info + - run: "docker run --name bmo --entrypoint true bmo" + - run: "docker cp bmo:/app/version.json build_info/version.json" + - store_artifacts: + path: /app/build_info - deploy: command: | - if [[ -n "$DOCKERHUB_REPO" && -n "$DOCKER_USER" && -n "$DOCKER_PASS" ]]; then - TAG="" - if [[ -n "$CIRCLE_TAG" ]]; then - TAG="$CIRCLE_TAG" - elif [[ "$CIRCLE_BRANCH" == "master" ]]; then - TAG=latest - elif [[ "$CIRCLE_BRANCH" == "unstable" ]]; then - TAG=unstable - fi - if [[ -n "$TAG" ]]; then - docker tag bmo "$DOCKERHUB_REPO:$TAG" - docker login -u "$DOCKER_USER" -p "$DOCKER_PASS" - docker push "$DOCKERHUB_REPO:$TAG" - fi + TAG="$(cat /app/build_info/tag.txt)" + [[ "$CIRCLE_BRANCH" == "master" ]] || exit 0 + [[ -n "$DOCKERHUB_REPO" && -n "$DOCKER_USER" && -n "$DOCKER_PASS" ]] || exit 0 + [[ -n "$GITHUB_PERSONAL_TOKEN" ]] || exit 0 + docker login -u "$DOCKER_USER" -p "$DOCKER_PASS" + if [[ -n "$TAG" && -f build_info/publish.txt ]]; then + git config credential.helper "cache --timeout 120" + git config user.email "$GITHUB_EMAIL" + git config user.name "$GITHUB_NAME" + git tag $TAG + git push https://${GITHUB_PERSONAL_TOKEN}:x-oauth-basic@github.com/$GITHUB_REPO.git $TAG + docker tag bmo "$DOCKERHUB_REPO:$TAG" + docker push "$DOCKERHUB_REPO:$TAG" fi + docker tag bmo "$DOCKERHUB_REPO:latest" + docker push "$DOCKERHUB_REPO:latest" test_sanity: - parallelism: 4 + parallelism: 2 working_directory: /app docker: - <<: *bmo_slim_image environment: *bmo_env steps: - checkout + - attach_workspace: + at: /app/build_info - run: | + [[ -f build_info/only_version_changed.txt ]] && exit 0 mv /opt/bmo/local /app/local mkdir artifacts - - run: perl Makefile.PL + - run: | + [[ -f build_info/only_version_changed.txt ]] && exit 0 + perl Makefile.PL - run: name: run sanity tests command: | + [[ -f build_info/only_version_changed.txt ]] && exit 0 /app/scripts/entrypoint.pl prove -qf $(circleci tests glob 't/*.t' | circleci tests split) | tee artifacts/$CIRCLE_JOB.txt - store_artifacts: path: /app/artifacts @@ -128,12 +188,15 @@ jobs: docker: *docker_oldtests steps: - checkout + - attach_workspace: + at: /app/build_info - *default_qa_setup - run: | + [[ -f build_info/only_version_changed.txt ]] && exit 0 /app/scripts/entrypoint.pl load_test_data - - run: - command: | - /app/scripts/entrypoint.pl test_webservices | tee artifacts/$CIRCLE_JOB.txt + - run: | + [[ -f build_info/only_version_changed.txt ]] && exit 0 + /app/scripts/entrypoint.pl test_webservices | tee artifacts/$CIRCLE_JOB.txt - store_artifacts: path: /app/artifacts @@ -143,12 +206,15 @@ jobs: docker: *docker_oldtests steps: - checkout + - attach_workspace: + at: /app/build_info - *default_qa_setup - run: | + [[ -f build_info/only_version_changed.txt ]] && exit 0 /app/scripts/entrypoint.pl load_test_data --legacy - - run: - command: | - /app/scripts/entrypoint.pl test_selenium | tee artifacts/$CIRCLE_JOB.txt + - run: | + [[ -f build_info/only_version_changed.txt ]] && exit 0 + /app/scripts/entrypoint.pl test_selenium | tee artifacts/$CIRCLE_JOB.txt - store_artifacts: path: /app/artifacts @@ -169,34 +235,45 @@ jobs: - image: selenium/standalone-firefox:2.53.1 steps: - checkout + - attach_workspace: + at: /app/build_info - run: | + [[ -f build_info/only_version_changed.txt ]] && exit 0 mv /opt/bmo/local /app/local /app/scripts/entrypoint.pl checksetup_gen_files /app/scripts/entrypoint.pl load_test_data mkdir artifacts - - run: /app/scripts/entrypoint.pl test_bmo -q -f t/bmo/*.t + - run: | + [[ -f build_info/only_version_changed.txt ]] && exit 0 + /app/scripts/entrypoint.pl test_bmo -q -f t/bmo/*.t workflows: version: 2 main: jobs: + - build_info: + filters: *main_filters + - build: + filters: *main_filters + requires: + - build_info + - test_sanity + - test_bmo + - test_webservices + - test_selenium - test_sanity: filters: *main_filters + requires: + - build_info - test_bmo: filters: *main_filters requires: - - test_sanity + - build_info - test_webservices: filters: *main_filters requires: - - test_sanity + - build_info - test_selenium: filters: *main_filters requires: - - test_sanity - - build: - filters: *main_filters - requires: - - test_sanity - - test_bmo - - test_webservices + - build_info |