]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 1886342: Move docker-based tests from CircleCI into GitHub Actions (#113)
authorDave Miller <justdave@bugzilla.org>
Fri, 22 Mar 2024 01:48:22 +0000 (21:48 -0400)
committerGitHub <noreply@github.com>
Fri, 22 Mar 2024 01:48:22 +0000 (21:48 -0400)
* Bug 1886342: Move docker-based tests from CircleCI into GitHub Actions

.circleci/build.sh [deleted file]
.circleci/config.yml [deleted file]
.circleci/deploy.pl [deleted file]
.circleci/deploy.sh [deleted file]
.github/checksetup_answers.txt [moved from .circleci/checksetup_answers.txt with 100% similarity]
.github/selenium_test.conf [moved from .circleci/selenium_test.conf with 100% similarity]
.github/workflows/ci.yml [new file with mode: 0644]
docker-compose.test.yml
t/docker.t [deleted file]

diff --git a/.circleci/build.sh b/.circleci/build.sh
deleted file mode 100644 (file)
index 7d476c8..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-#!/bin/bash
-
-set -euf -o pipefail
-
-docker build \
-    --build-arg CI="$CI" \
-    --build-arg CIRCLE_SHA1="$CIRCLE_SHA1" \
-    --build-arg CIRCLE_BUILD_URL="$CIRCLE_BUILD_URL" \
-    -t bmo .
-
-docker run --name bmo --entrypoint true bmo
-docker cp bmo:/app/version.json build_info/version.json
diff --git a/.circleci/config.yml b/.circleci/config.yml
deleted file mode 100644 (file)
index ed911d6..0000000
+++ /dev/null
@@ -1,253 +0,0 @@
-# References:
-# 1. https://circleci.com/blog/how-to-build-a-docker-image-on-circleci-2-0/
-# 2. https://circleci.com/docs/2.0/building-docker-images/
-#
-
-version: 2.1
-
-defaults:
-  docker_image: &docker_image
-    image: cimg/base:current
-
-  build_image: &build_image
-    run:
-      name: Build Docker BMO image
-      command: |
-        docker compose -f docker-compose.test.yml build
-      environment:
-        DOCKER_BUILDKIT: 1
-
-  store_log: &store_log
-    store_artifacts:
-      path: /tmp/bzbuild/bugzilla.log
-      destination: bugzilla.log
-
-  main_filters: &main_filters
-    branches:
-      ignore:
-        - /^(?:release|test)-20\d\d\d\d\d\d\.\d+/
-        - /\//
-        - production
-
-jobs:
-  build_info:
-    parallelism: 1
-    working_directory: /tmp/bzbuild
-    docker:
-      - *docker_image
-    steps:
-      - setup_remote_docker:
-          version: default
-          docker_layer_caching: true
-      - checkout
-      - *build_image
-      - run: |
-          [[ -d build_info ]] || mkdir build_info
-      - attach_workspace:
-          at: /tmp/bzbuild/build_info
-      - run: |
-          docker compose -f docker-compose.test.yml run --name version_json --entrypoint true bmo.test
-          docker cp version_json:/app/version.json build_info/version.json
-          docker rm version_json
-#      - run:
-#          name: build push data
-#          command: |
-#            docker compose -f docker-compose.test.yml run --name push_data bmo.test push_data
-#            docker cp push_data:/app/build_info/blog.push.txt build_info/blog.push.txt
-#            docker cp push_data:/app/build_info/bug.push.txt build_info/bug.push.txt
-#            docker cp push_data:/app/build_info/email.push.txt build_info/email.push.txt
-#            docker cp push_data:/app/build_info/tag.txt build_info/tag.txt
-#            docker cp push_data:/app/build_info/wiki.push.txt build_info/wiki.push.txt
-#            docker rm push_data
-#      - run:
-#          name: only publish if tag exists
-#          command: |
-#            git fetch --tags
-#            tag="$(cat build_info/tag.txt)"
-#            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: /tmp/bzbuild/build_info
-#          paths: ["*.txt"]
-      - store_artifacts:
-          path: /tmp/bzbuild/build_info
-      - *store_log
-
-  build:
-    parallelism: 1
-    working_directory: /tmp/bzbuild
-    docker:
-      - *docker_image
-    steps:
-      - setup_remote_docker:
-          version: default
-          docker_layer_caching: true
-      - checkout
-      - *build_image
-      - attach_workspace:
-          at: /tmp/bzbuild/build_info
-      - deploy:
-          command: |
-            [[ -n "$DOCKERHUB_REPO" && -n "$DOCKER_USER" && -n "$DOCKER_PASS" ]] || exit 0
-            docker login -u "$DOCKER_USER" -p "$DOCKER_PASS"
-            if [[ "$CIRCLE_BRANCH" == "master" ]]; then
-              TAG="$(cat build_info/tag.txt)"
-              if [[ -n "$TAG" && -f build_info/publish.txt ]]; then
-                [[ -n "$GITHUB_PERSONAL_TOKEN" ]] || exit 0
-                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"
-            else
-              docker tag bmo "$DOCKERHUB_REPO:$CIRCLE_BRANCH"
-              docker push "$DOCKERHUB_REPO:$CIRCLE_BRANCH"
-            fi
-
-  test_sanity:
-    parallelism: 1
-    working_directory: /tmp/bzbuild
-    docker:
-      - *docker_image
-    steps:
-      - setup_remote_docker:
-          version: default
-          docker_layer_caching: true
-      - checkout
-      - *build_image
-      - run: |
-          [[ -d artifacts ]] || mkdir artifacts
-      - attach_workspace:
-          at: /tmp/bzbuild/build_info
-      - run:
-          name: run sanity tests
-          command: |
-            [[ -f build_info/only_version_changed.txt ]] && exit 0
-            docker compose -f docker-compose.test.yml run --no-deps bmo.test \
-              test_sanity $(circleci tests glob 't/*.t' 'extensions/*/t/*.t' | \
-              circleci tests split) | tee artifacts/$CIRCLE_JOB.txt
-      - store_artifacts:
-          path: /tmp/bzbuild/artifacts
-      - *store_log
-
-  test_webservices:
-    parallelism: 1
-    working_directory: /tmp/bzbuild
-    docker:
-      - *docker_image
-    steps:
-      - setup_remote_docker:
-          version: default
-          docker_layer_caching: true
-      - checkout
-      - *build_image
-      - run: |
-          [[ -d artifacts ]] || mkdir artifacts
-      - attach_workspace:
-          at: /tmp/bzbuild/build_info
-      - run: |
-          [[ -f build_info/only_version_changed.txt ]] && exit 0
-          docker compose -f docker-compose.test.yml run bmo.test test_webservices | \
-            tee artifacts/$CIRCLE_JOB.txt
-      - store_artifacts:
-          path: /tmp/bzbuild/artifacts
-      - *store_log
-
-  test_selenium:
-    parallelism: 1
-    working_directory: /tmp/bzbuild
-    docker:
-      - *docker_image
-    steps:
-      - setup_remote_docker:
-          version: default
-          docker_layer_caching: true
-      - checkout
-      - *build_image
-      - run: |
-          [[ -d artifacts ]] || mkdir artifacts
-      - attach_workspace:
-          at: /tmp/bzbuild/build_info
-      - run: |
-          [[ -f build_info/only_version_changed.txt ]] && exit 0
-          docker compose -f docker-compose.test.yml run bmo.test test_selenium | \
-            tee artifacts/$CIRCLE_JOB.txt
-      - store_artifacts:
-          path: /tmp/bzbuild/artifacts
-      - *store_log
-
-  test_bmo:
-    parallelism: 1
-    working_directory: /tmp/bzbuild
-    docker:
-      - *docker_image
-    steps:
-      - setup_remote_docker:
-          version: default
-          docker_layer_caching: true
-      - checkout
-      - *build_image
-      - run: |
-          [[ -d artifacts ]] || mkdir artifacts
-      - attach_workspace:
-          at: /tmp/bzbuild/build_info
-      - run: |
-          [[ -f build_info/only_version_changed.txt ]] && exit 0
-          docker compose -f docker-compose.test.yml run bmo.test test_bmo -q -f t/bmo/*.t
-      - *store_log
-
-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:
-            - build_info
-#      - test_webservices:
-#          filters: *main_filters
-#          requires:
-#            - build_info
-#      - test_selenium:
-#          filters: *main_filters
-#          requires:
-#            - build_info
diff --git a/.circleci/deploy.pl b/.circleci/deploy.pl
deleted file mode 100755 (executable)
index 5c7d648..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-#!/usr/bin/env perl
-use 5.10.1;
-use strict;
-use warnings;
-
-my ($repo, $user, $pass)
-  = check_env(qw(DOCKERHUB_REPO DOCKER_USER DOCKER_PASS));
-run("docker", "login", "-u", $user, "-p", $pass);
-
-my @docker_tags = ($ENV{CIRCLE_SHA1});
-
-if ($ENV{CIRCLE_TAG}) {
-  push @docker_tags, $ENV{CIRCLE_TAG};
-}
-elsif ($ENV{CIRCLE_BRANCH}) {
-  if ($ENV{CIRCLE_BRANCH} eq 'master') {
-    push @docker_tags, 'latest';
-  }
-  else {
-    push @docker_tags, $ENV{CIRCLE_BRANCH};
-  }
-}
-
-say "Pushing tags...";
-say "  $_" for @docker_tags;
-foreach my $tag (@docker_tags) {
-  run("docker", "tag", "bmo", "$repo:$tag");
-  run("docker", "push", "$repo:$tag");
-}
-
-sub run {
-  my (@cmd) = @_;
-  my $rv = system(@cmd);
-  exit 1 if $rv != 0;
-}
-
-sub check_env {
-  my (@missing, @found);
-  foreach my $name (@_) {
-    push @missing, $name unless $ENV{$name};
-    push @found, $ENV{$name};
-  }
-
-  if (@missing) {
-    warn "Missing environmental variables: ", join(", ", @missing), "\n";
-    exit;
-  }
-  return @found;
-}
-
-
diff --git a/.circleci/deploy.sh b/.circleci/deploy.sh
deleted file mode 100644 (file)
index 3d8a385..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-#!/bin/bash
-
-set -euf -o pipefail
-
-[[ -n "$DOCKERHUB_REPO" && -n "$DOCKER_USER" && -n "$DOCKER_PASS" ]] || exit 0
-docker login -u "$DOCKER_USER" -p "$DOCKER_PASS"
-
-if [[ "$CIRCLE_BRANCH" == "master" ]]; then
-    TAG="$(cat /app/build_info/tag.txt)"
-    [[ -n "$GITHUB_PERSONAL_TOKEN" ]] || exit 0
-    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"
-elif [[ "$CIRCLE_BRANCH" == "development" ]]; then
-    docker tag bmo "$DOCKERHUB_REPO:build-${CIRCLE_BUILD_NUM}"
-    docker push "$DOCKERHUB_REPO:build-${CIRCLE_BUILD_NUM}"
-fi
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
new file mode 100644 (file)
index 0000000..b3a6a5b
--- /dev/null
@@ -0,0 +1,39 @@
+name: Bugzilla Test Suite
+
+on:
+  pull_request
+
+jobs:
+  test_sanity:
+    runs-on: ubuntu-latest
+    steps:
+      - uses: actions/checkout@v3
+      - name: Install docker-compose
+        run: sudo apt update && sudo apt install -y docker-compose
+      - name: Build the Docker images
+        run: docker compose -f docker-compose.test.yml build
+      - name: Run sanity tests
+        run: docker-compose -f docker-compose.test.yml run --no-deps bmo.test test_sanity t/*.t extensions/*/t/*.t
+
+#  test_webservices:
+#    runs-on: ubuntu-latest
+#    steps:
+#      - uses: actions/checkout@v3
+#      - name: Install docker-compose
+#        run: sudo apt update && sudo apt install -y docker-compose
+#      - name: Build the Docker images
+#        run: docker compose -f docker-compose.test.yml build
+#      - name: Run webservice tests
+#        run: docker-compose -f docker-compose.test.yml run bmo.test test_webservices
+
+  test_bmo:
+    runs-on: ubuntu-latest
+    steps:
+      - uses: actions/checkout@v3
+      - name: Install docker-compose
+        run: sudo apt update && sudo apt install -y docker-compose
+      - name: Build the Docker images
+        run: docker compose -f docker-compose.test.yml build
+      - name: Run bmo specific tests
+        run: docker-compose -f docker-compose.test.yml run -e CI=1 bmo.test test_bmo -q -f t/bmo/*.t
+
index 923d1b096933bd7ff6280d2e59e51a6aea0cd22d..7bbedee745ec07c52b40f77cde2d05de515abc90 100644 (file)
@@ -27,8 +27,8 @@ services:
       - BMO_urlbase=AUTOMATIC
       - BUGZILLA_ALLOW_INSECURE_HTTP=1
       - BZ_ANSWERS_FILE=/app/conf/checksetup_answers.txt
-      - BZ_QA_ANSWERS_FILE=/app/.circleci/checksetup_answers.txt
-      - BZ_QA_CONF_FILE=/app/.circleci/selenium_test.conf
+      - BZ_QA_ANSWERS_FILE=/app/.github/checksetup_answers.txt
+      - BZ_QA_CONF_FILE=/app/.github/selenium_test.conf
       - BZ_QA_CONFIG=1
       - CI=${CI}
       - CIRCLE_SHA1=${CIRCLE_SHA1}
diff --git a/t/docker.t b/t/docker.t
deleted file mode 100644 (file)
index 24033ba..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-#!/usr/bin/env perl
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-#
-# This Source Code Form is "Incompatible With Secondary Licenses", as
-# defined by the Mozilla Public License, v. 2.0.
-use 5.10.1;
-use strict;
-use warnings;
-use autodie;
-use lib qw(. lib local/lib/perl5);
-use IO::Handle;
-use Test::More;
-
-my $dockerfile = 'Dockerfile.bmo-slim';
-my $ci_config  = '.circleci/config.yml';
-
-my $base;
-open my $dockerfile_fh, '<', $dockerfile;
-while (my $line = readline $dockerfile_fh) {
-  chomp $line;
-  if ($line =~ /^FROM\s+(\S+)/ms) {
-    $base = $1;
-    last;
-  }
-}
-close $dockerfile_fh;
-
-my ($image, $version) = split(/:/ms, $base, 2);
-is($image, 'perl', 'base image is Perl');
-like($version, qr/\d{1}\.\d{2}\.\d{1}-slim/ms, "version is x.xx.x-slim");
-
-my $regex = qr{
-    \Q$image\E
-    :
-    (?!\Q$version\E)
-    (\d{4}\d{2}\d{2}\.\d+)
-}msx;
-
-open my $ci_config_fh, '<', $ci_config;
-while (my $line = readline $ci_config_fh) {
-  chomp $line;
-  if ($line =~ /($regex)/ms) {
-    my $ln = $ci_config_fh->input_line_number;
-    fail("found docker image $1, expected $base in $ci_config line $ln");
-  }
-  pass("Forbidden version not found");
-}
-close $ci_config_fh;
-
-done_testing;