|
| 1 | +name: Test scaffold |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + - develop |
| 8 | + pull_request: |
| 9 | + types: |
| 10 | + - opened |
| 11 | + - reopened |
| 12 | + - ready_for_review |
| 13 | + - synchronize |
| 14 | + schedule: |
| 15 | + # Sunday 2 AM Melbourne time. |
| 16 | + - cron: '0 16 * * SUN' |
| 17 | + workflow_dispatch: |
| 18 | + |
| 19 | +concurrency: |
| 20 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 21 | + cancel-in-progress: true |
| 22 | + |
| 23 | +env: |
| 24 | + DREVOPS_CI_TEST_RESULTS: /tmp/tests |
| 25 | + DREVOPS_CI_ARTIFACTS: /tmp/artifacts |
| 26 | + GOVCMS_VERSION: 10 |
| 27 | + |
| 28 | +jobs: |
| 29 | + test: |
| 30 | + runs-on: ubuntu-latest |
| 31 | + strategy: |
| 32 | + max-parallel: 2 |
| 33 | + matrix: |
| 34 | + govcms_image: |
| 35 | + - "10.x-latest" |
| 36 | + - "10.x-edge" |
| 37 | + project_type: |
| 38 | + - saas |
| 39 | + - paas |
| 40 | + fail-fast: false |
| 41 | + |
| 42 | + container: |
| 43 | + image: drevops/ci-runner:24.8.0 |
| 44 | + env: |
| 45 | + CI: 1 |
| 46 | + # Prevent GitHub overriding the Docker config. |
| 47 | + DOCKER_CONFIG: /root/.docker |
| 48 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 49 | + TZ: "Australia/Melbourne" |
| 50 | + # Set runner terminal capabilities. |
| 51 | + TERM: xterm-256color |
| 52 | + # Directory to store test results. |
| 53 | + DREVOPS_CI_TEST_RESULTS: ${{ env.DREVOPS_CI_TEST_RESULTS }} |
| 54 | + # Directory to store test artifacts. |
| 55 | + DREVOPS_CI_ARTIFACTS: ${{ env.DREVOPS_CI_ARTIFACTS }} |
| 56 | + # Check only minimal stack requirements. |
| 57 | + DREVOPS_DOCTOR_CHECK_MINIMAL: 1 |
| 58 | + # Directory to store code exported between jobs. |
| 59 | + DREVOPS_EXPORT_CODE_DIR: /tmp/workspace/code |
| 60 | + |
| 61 | + steps: |
| 62 | + - |
| 63 | + name: Checkout the repo |
| 64 | + uses: actions/checkout@main |
| 65 | + |
| 66 | + - |
| 67 | + name: Check Docker and Compose version |
| 68 | + run: | |
| 69 | + echo "[INFO] Docker version." |
| 70 | + docker version |
| 71 | + echo "[INFO] Docker Compose version." |
| 72 | + docker compose version |
| 73 | +
|
| 74 | + - |
| 75 | + name: Setup Docker network |
| 76 | + 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 |
| 77 | + |
| 78 | + - |
| 79 | + name: Process codebase to run in CI |
| 80 | + run: | |
| 81 | + 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#[]#' {}" |
| 82 | + mkdir -p "${DREVOPS_EXPORT_CODE_DIR}" |
| 83 | +
|
| 84 | + - |
| 85 | + name: Init scaffold |
| 86 | + run: ahoy init scaffold-test ${{ matrix.project_type }} ${{ env.GOVCMS_VERSION }} |
| 87 | + |
| 88 | + - |
| 89 | + name: Build project |
| 90 | + run: ahoy up |
| 91 | + env: |
| 92 | + GOVCMS_IMAGE_VERSION: ${{ matrix.govcms_image }} |
| 93 | + GOVCMS_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 94 | + |
| 95 | + - |
| 96 | + name: Install GovCMS profile |
| 97 | + run: ahoy install |
| 98 | + |
| 99 | + notify: |
| 100 | + runs-on: ubuntu-latest |
| 101 | + needs: [ test ] |
| 102 | + if: ${{ !cancelled() }} |
| 103 | + steps: |
| 104 | + - |
| 105 | + name: Notify failures to Slack |
| 106 | + id: failure_slack |
| 107 | + if: ${{ contains(needs.*.result, 'failure') }} |
| 108 | + uses: slackapi/slack-github-action@v1.27.0 |
| 109 | + with: |
| 110 | + # See https://github.com/slackapi/slack-github-action?tab=readme-ov-file |
| 111 | + channel-id: ${{ secrets.SLACK_CHANNEL }} |
| 112 | + payload: | |
| 113 | + { |
| 114 | + "attachments": [ |
| 115 | + { |
| 116 | + "color": "#ff0000", |
| 117 | + "blocks": [ |
| 118 | + { |
| 119 | + "type": "header", |
| 120 | + "text": { |
| 121 | + "type": "plain_text", |
| 122 | + "text": "GovCMS Scaffold test failure" |
| 123 | + } |
| 124 | + }, |
| 125 | + { |
| 126 | + "type": "context", |
| 127 | + "elements": [ |
| 128 | + { |
| 129 | + "type": "mrkdwn", |
| 130 | + "text": "Some jobs were not successful, please view the pipeline and rerun." |
| 131 | + } |
| 132 | + ] |
| 133 | + }, |
| 134 | + { |
| 135 | + "type": "actions", |
| 136 | + "block_id": "view_pipeline", |
| 137 | + "elements": [ |
| 138 | + { |
| 139 | + "type": "button", |
| 140 | + "text": { |
| 141 | + "type": "plain_text", |
| 142 | + "text": "View pipeline" |
| 143 | + }, |
| 144 | + "url": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" |
| 145 | + } |
| 146 | + ] |
| 147 | + } |
| 148 | + ] |
| 149 | + } |
| 150 | + ] |
| 151 | + } |
| 152 | + env: |
| 153 | + SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} |
0 commit comments