From 56ccda5e453cd30eeb21de4f9c9bf3af2f577730 Mon Sep 17 00:00:00 2001 From: Steve Worley Date: Fri, 30 Aug 2024 10:10:43 +1000 Subject: [PATCH 01/11] Remove additional copies. --- .docker/Dockerfile.test | 8 -------- 1 file changed, 8 deletions(-) diff --git a/.docker/Dockerfile.test b/.docker/Dockerfile.test index fe025fe..bbf29f9 100644 --- a/.docker/Dockerfile.test +++ b/.docker/Dockerfile.test @@ -12,11 +12,3 @@ ENV WEBROOT=web COPY --from=cli /app /app COPY tests /app/tests/ - -# Copy deploy and test scripts. -RUN cp /app/vendor/govcms/scaffold-tooling/scripts/govcms* /usr/local/bin/ -RUN chmod +x /usr/local/bin/* - -# @see also drush setup in Dockerfile.cli -COPY --from=cli /usr/local/bin/drush /usr/local/bin/ -RUN chmod +x /usr/local/bin/drush && rm -Rf /home/.composer/vendor/bin \ No newline at end of file From 45347fc75b1a32490d792ebee007d51083b6af17 Mon Sep 17 00:00:00 2001 From: Steve Worley Date: Tue, 3 Sep 2024 09:01:13 +1000 Subject: [PATCH 02/11] Update .gitignore Fixes #66 --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index d9722a0..f40cefe 100644 --- a/.gitignore +++ b/.gitignore @@ -29,3 +29,6 @@ console # Local development tools. docker-compose.override.yml + +# Local data directory. +.data From b3991b4d499702a489b3e712bd83c2949362901c Mon Sep 17 00:00:00 2001 From: Sonny Kieu Date: Tue, 3 Sep 2024 13:20:10 +1000 Subject: [PATCH 03/11] [DEVOPS-615] Added Github workflow to test the scaffold. --- .github/workflows/test-scaffold.yml | 107 ++++++++++++++++++++++++++++ 1 file changed, 107 insertions(+) create mode 100644 .github/workflows/test-scaffold.yml diff --git a/.github/workflows/test-scaffold.yml b/.github/workflows/test-scaffold.yml new file mode 100644 index 0000000..b1546ff --- /dev/null +++ b/.github/workflows/test-scaffold.yml @@ -0,0 +1,107 @@ +name: Test scaffold + +on: + push: + branches: + - main + - develop + pull_request: + types: + - opened + - reopened + - ready_for_review + - synchronize + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +env: + DREVOPS_CI_TEST_RESULTS: /tmp/tests + DREVOPS_CI_ARTIFACTS: /tmp/artifacts + GOVCMS_VERSION: 10 + +jobs: + test: + runs-on: ubuntu-latest + strategy: + max-parallel: 2 + matrix: + govcms_image: + - "10.x-latest" + - "10.x-edge" + project_type: + - saas + - paas + fail-fast: false + + container: + image: drevops/ci-runner:24.1.0 + env: + CI: 1 + # Prevent GitHub overriding the Docker config. + DOCKER_CONFIG: /root/.docker + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + TZ: "Australia/Melbourne" + # Set runner terminal capabilities. + TERM: xterm-256color + # How often to refresh the cache of the DB dump. Refer to `date` command. + DREVOPS_CI_DB_CACHE_TIMESTAMP: "+%Y%m%d" + # Use cache fallback if the above timestamp does not match. + DREVOPS_CI_DB_CACHE_FALLBACK: "yes" + # Which branch to use as a source of DB caches. + DREVOPS_CI_DB_CACHE_BRANCH: "develop" + # Directory to store test results. + DREVOPS_CI_TEST_RESULTS: ${{ env.DREVOPS_CI_TEST_RESULTS }} + # Directory to store test artifacts. + DREVOPS_CI_ARTIFACTS: ${{ env.DREVOPS_CI_ARTIFACTS }} + # Check only minimal stack requirements. + DREVOPS_DOCTOR_CHECK_MINIMAL: 1 + # Directory to store code exported between jobs. + DREVOPS_EXPORT_CODE_DIR: /tmp/workspace/code + # Directory to use for artifact deployments. + DREVOPS_DEPLOY_ARTIFACT_SRC: "" + # Source code location for artifact deployments. + DREVOPS_DEPLOY_ARTIFACT_ROOT: . + # Report file location for artifact deployments. + DREVOPS_DEPLOY_ARTIFACT_REPORT_FILE: /tmp/artifacts/deployment_report.txt + + steps: + - + name: Checkout the repo + uses: actions/checkout@main + + - + name: Check Docker and Compose version + run: | + echo "[INFO] Docker version." + docker version + echo "[INFO] Docker Compose version." + docker compose version + + - + name: Setup Docker network + run: docker network prune -f >/dev/null 2>&1 && docker network inspect amazeeio-network >/dev/null 2>&1 || docker network create amazeeio-network >/dev/null 2>&1 || true + + - + name: Process codebase to run in CI + run: | + find . -name "docker-compose.yml" -print0 | xargs -0 -I {} sh -c "sed -i -e ''/###/d'' {} && sed -i -e ''s/##//'' {} && sed -i -e 's#- .:/app:delegated##' {}" + mkdir -p /tmp/workspace/code + + - + name: Init scaffold + run: ahoy init scaffold-test ${{ matrix.project_type }} ${{ env.GOVCMS_VERSION }} + + - + name: Build project + run: ahoy up + env: + GOVCMS_IMAGE_VERSION: ${{ matrix.govcms_image }} + GOVCMS_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - + name: Install GovCMS profile + run: ahoy install + From b11a5985bd9e22aa75436be692c0f0f52dac9335 Mon Sep 17 00:00:00 2001 From: Sonny Kieu Date: Tue, 3 Sep 2024 16:49:49 +1000 Subject: [PATCH 04/11] [DEVOPS-615] Added Slack notification. --- .github/workflows/test-scaffold.yml | 86 ++++++++++++++++++++++++----- 1 file changed, 71 insertions(+), 15 deletions(-) diff --git a/.github/workflows/test-scaffold.yml b/.github/workflows/test-scaffold.yml index b1546ff..802e57f 100644 --- a/.github/workflows/test-scaffold.yml +++ b/.github/workflows/test-scaffold.yml @@ -37,7 +37,7 @@ jobs: fail-fast: false container: - image: drevops/ci-runner:24.1.0 + image: drevops/ci-runner:24.8.0 env: CI: 1 # Prevent GitHub overriding the Docker config. @@ -46,12 +46,6 @@ jobs: TZ: "Australia/Melbourne" # Set runner terminal capabilities. TERM: xterm-256color - # How often to refresh the cache of the DB dump. Refer to `date` command. - DREVOPS_CI_DB_CACHE_TIMESTAMP: "+%Y%m%d" - # Use cache fallback if the above timestamp does not match. - DREVOPS_CI_DB_CACHE_FALLBACK: "yes" - # Which branch to use as a source of DB caches. - DREVOPS_CI_DB_CACHE_BRANCH: "develop" # Directory to store test results. DREVOPS_CI_TEST_RESULTS: ${{ env.DREVOPS_CI_TEST_RESULTS }} # Directory to store test artifacts. @@ -60,12 +54,6 @@ jobs: DREVOPS_DOCTOR_CHECK_MINIMAL: 1 # Directory to store code exported between jobs. DREVOPS_EXPORT_CODE_DIR: /tmp/workspace/code - # Directory to use for artifact deployments. - DREVOPS_DEPLOY_ARTIFACT_SRC: "" - # Source code location for artifact deployments. - DREVOPS_DEPLOY_ARTIFACT_ROOT: . - # Report file location for artifact deployments. - DREVOPS_DEPLOY_ARTIFACT_REPORT_FILE: /tmp/artifacts/deployment_report.txt steps: - @@ -87,8 +75,8 @@ jobs: - name: Process codebase to run in CI run: | - find . -name "docker-compose.yml" -print0 | xargs -0 -I {} sh -c "sed -i -e ''/###/d'' {} && sed -i -e ''s/##//'' {} && sed -i -e 's#- .:/app:delegated##' {}" - mkdir -p /tmp/workspace/code + find . -name "docker-compose.yml" -print0 | xargs -0 -I {} sh -c "sed -i -e ''/###/d'' {} && sed -i -e ''s/##//'' {} && sed -i -e 's#- .:/app:delegated#[]#' {}" + mkdir -p "${DREVOPS_EXPORT_CODE_DIR}" - name: Init scaffold @@ -105,3 +93,71 @@ jobs: name: Install GovCMS profile run: ahoy install + notify: + runs-on: ubuntu-latest + needs: [ test ] + if: ${{ !cancelled() }} + steps: + - + name: Notify failures to Slack + id: failure_slack + if: ${{ contains(needs.*.result, 'failure') }} + uses: slackapi/slack-github-action@v1.27.0 + with: + # See https://github.com/slackapi/slack-github-action?tab=readme-ov-file + channel-id: ${{ vars.SLACK_CHANNEL }} + payload: | + { + "attachments": [ + { + "color": "#ff0000", + "blocks": [ + { + "type": "header", + "text": { + "type": "plain_text", + "text": "Scaffold test failure" + } + }, + { + "type": "context", + "elements": [ + { + "type": "mrkdwn", + "text": "Some jobs were not successful, please view the pipeline and rerun." + } + ] + }, + { + "type": "section", + "fields": [ + { + "type": "mrkdwn", + "text": "*Project Type:*\${{ matrix.project_type }}" + }, + { + "type": "mrkdwn", + "text": "*GovCMS Image:*\n${{ matrix.govcms_image }}" + } + ] + }, + { + "type": "actions", + "block_id": "view_pipeline", + "elements": [ + { + "type": "button", + "text": { + "type": "plain_text", + "text": "View pipeline" + }, + "url": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" + } + ] + } + ] + } + ] + } + env: + SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} From 5daff02b0888572f772fd8529481dee3f710c5dd Mon Sep 17 00:00:00 2001 From: Steve Worley Date: Wed, 4 Sep 2024 09:48:46 +1000 Subject: [PATCH 05/11] Remove conditions for notification testing. --- .github/workflows/test-scaffold.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/test-scaffold.yml b/.github/workflows/test-scaffold.yml index 802e57f..bee0acd 100644 --- a/.github/workflows/test-scaffold.yml +++ b/.github/workflows/test-scaffold.yml @@ -96,12 +96,10 @@ jobs: notify: runs-on: ubuntu-latest needs: [ test ] - if: ${{ !cancelled() }} steps: - name: Notify failures to Slack id: failure_slack - if: ${{ contains(needs.*.result, 'failure') }} uses: slackapi/slack-github-action@v1.27.0 with: # See https://github.com/slackapi/slack-github-action?tab=readme-ov-file From 9a1223299c72948f1fd68b2c9a08269c5795fb4e Mon Sep 17 00:00:00 2001 From: Steve Worley Date: Wed, 4 Sep 2024 10:05:58 +1000 Subject: [PATCH 06/11] Update the JSON structure. --- .github/workflows/test-scaffold.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-scaffold.yml b/.github/workflows/test-scaffold.yml index bee0acd..f21beaf 100644 --- a/.github/workflows/test-scaffold.yml +++ b/.github/workflows/test-scaffold.yml @@ -131,7 +131,7 @@ jobs: "fields": [ { "type": "mrkdwn", - "text": "*Project Type:*\${{ matrix.project_type }}" + "text": "*Project Type:*\n${{ matrix.project_type }}" }, { "type": "mrkdwn", From f8a4655d690d635bc25d6c04bafa17d4c73d6ab4 Mon Sep 17 00:00:00 2001 From: Steve Worley Date: Wed, 4 Sep 2024 10:28:03 +1000 Subject: [PATCH 07/11] Move channel ID to secrets for now. --- .github/workflows/test-scaffold.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-scaffold.yml b/.github/workflows/test-scaffold.yml index f21beaf..98575ab 100644 --- a/.github/workflows/test-scaffold.yml +++ b/.github/workflows/test-scaffold.yml @@ -103,7 +103,7 @@ jobs: uses: slackapi/slack-github-action@v1.27.0 with: # See https://github.com/slackapi/slack-github-action?tab=readme-ov-file - channel-id: ${{ vars.SLACK_CHANNEL }} + channel-id: ${{ secrets.SLACK_CHANNEL }} payload: | { "attachments": [ From 2db2640852880f34ebda29f91a7843902d040ab1 Mon Sep 17 00:00:00 2001 From: Sonny Kieu Date: Wed, 4 Sep 2024 11:48:35 +1000 Subject: [PATCH 08/11] [DEVOPS-615] Updated JSON payload. --- .github/workflows/test-scaffold.yml | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/.github/workflows/test-scaffold.yml b/.github/workflows/test-scaffold.yml index 98575ab..3a4a363 100644 --- a/.github/workflows/test-scaffold.yml +++ b/.github/workflows/test-scaffold.yml @@ -114,7 +114,7 @@ jobs: "type": "header", "text": { "type": "plain_text", - "text": "Scaffold test failure" + "text": "GovCMS Scaffold test failure" } }, { @@ -126,19 +126,6 @@ jobs: } ] }, - { - "type": "section", - "fields": [ - { - "type": "mrkdwn", - "text": "*Project Type:*\n${{ matrix.project_type }}" - }, - { - "type": "mrkdwn", - "text": "*GovCMS Image:*\n${{ matrix.govcms_image }}" - } - ] - }, { "type": "actions", "block_id": "view_pipeline", From 37bc84a4b39d282c3083770370794dd13f5b9d49 Mon Sep 17 00:00:00 2001 From: Steve Worley Date: Wed, 4 Sep 2024 12:48:01 +1000 Subject: [PATCH 09/11] Add failure condition. --- .github/workflows/test-scaffold.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/test-scaffold.yml b/.github/workflows/test-scaffold.yml index 3a4a363..713e70f 100644 --- a/.github/workflows/test-scaffold.yml +++ b/.github/workflows/test-scaffold.yml @@ -96,10 +96,12 @@ jobs: notify: runs-on: ubuntu-latest needs: [ test ] + if: ${{ !cancelled() }} steps: - name: Notify failures to Slack id: failure_slack + if: ${{ contains(needs.*.result, 'failure') }} uses: slackapi/slack-github-action@v1.27.0 with: # See https://github.com/slackapi/slack-github-action?tab=readme-ov-file From 609002ba544d666369b98b5d6d2d084d0abcd80f Mon Sep 17 00:00:00 2001 From: Sonny Kieu Date: Wed, 4 Sep 2024 13:24:00 +1000 Subject: [PATCH 10/11] [DEVOPS-615] Added schedule to run at 2am Sunday. --- .github/workflows/test-scaffold.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/test-scaffold.yml b/.github/workflows/test-scaffold.yml index 713e70f..6feb7c7 100644 --- a/.github/workflows/test-scaffold.yml +++ b/.github/workflows/test-scaffold.yml @@ -11,6 +11,9 @@ on: - reopened - ready_for_review - synchronize + schedule: + # Sunday 2 AM Melbourne time. + - cron: '0 16 * * SUN' workflow_dispatch: concurrency: From bb5adaee6e4cb9b40feed40894ca525a5bb4012d Mon Sep 17 00:00:00 2001 From: Steve Worley Date: Wed, 4 Sep 2024 15:48:55 +1000 Subject: [PATCH 11/11] Remove the Github Actions configuration on init. --- scripts/scaffold-init.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/scaffold-init.sh b/scripts/scaffold-init.sh index c729f1d..5289138 100755 --- a/scripts/scaffold-init.sh +++ b/scripts/scaffold-init.sh @@ -90,6 +90,9 @@ echo "[info]: Cleaning up" mv ".docker/Dockerfile.$GOVCMS_TYPE" .docker/Dockerfile.cli mv ".docker/Dockerfile.solr.$GOVCMS_TYPE" .docker/Dockerfile.solr +# Remove the GitHub Actions CI configuration. +rm -rf .github + if [[ "$GOVCMS_TYPE" == "paas" ]]; then rm .docker/Dockerfile*saas* rm -r themes