|
| 1 | +name: acceptance-stage |
| 2 | + |
| 3 | +on: |
| 4 | + schedule: |
| 5 | + - cron: '*/30 * * * *' # Run every 30 minutes |
| 6 | + workflow_dispatch: |
| 7 | + inputs: |
| 8 | + force_run: |
| 9 | + description: 'Force run (even if no new images)' |
| 10 | + required: false |
| 11 | + default: false |
| 12 | + type: boolean |
| 13 | + |
| 14 | +concurrency: |
| 15 | + group: acceptance-stage |
| 16 | + cancel-in-progress: true |
| 17 | + |
| 18 | +jobs: |
| 19 | + |
| 20 | + find-latest-images: |
| 21 | + runs-on: ubuntu-latest |
| 22 | + outputs: |
| 23 | + image-digest-urls: ${{ steps.get-digest.outputs.image-digest-urls }} |
| 24 | + latest-image-timestamp: ${{ steps.get-digest.outputs.latest-image-timestamp }} |
| 25 | + |
| 26 | + permissions: |
| 27 | + contents: read |
| 28 | + |
| 29 | + steps: |
| 30 | + - name: Checkout Repository |
| 31 | + uses: actions/checkout@v4 |
| 32 | + |
| 33 | + - name: Resolve Latest Docker Digests |
| 34 | + id: get-digest |
| 35 | + uses: optivem/find-latest-docker-images-action@v1 |
| 36 | + with: |
| 37 | + image-urls: | |
| 38 | + ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}/monolith:latest |
| 39 | +
|
| 40 | + should-run: |
| 41 | + needs: find-latest-images |
| 42 | + if: needs.find-latest-images.result == 'success' |
| 43 | + runs-on: ubuntu-latest |
| 44 | + outputs: |
| 45 | + should_run: ${{ steps.check.outputs.should-run }} |
| 46 | + steps: |
| 47 | + - name: Checkout Repository |
| 48 | + uses: actions/checkout@v4 |
| 49 | + with: |
| 50 | + fetch-depth: 0 |
| 51 | + |
| 52 | + - name: Should Run Acceptance Stage |
| 53 | + id: check |
| 54 | + uses: optivem/should-run-acceptance-stage-action@v1 |
| 55 | + with: |
| 56 | + latest-image-timestamp: ${{ needs.find-latest-images.outputs.latest-image-timestamp }} |
| 57 | + force-run: ${{ inputs.force_run == true }} |
| 58 | + env: |
| 59 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 60 | + |
| 61 | + |
| 62 | + |
| 63 | + system-test: |
| 64 | + needs: [should-run, find-latest-images] |
| 65 | + if: needs.should-run.outputs.should_run == 'true' |
| 66 | + runs-on: ubuntu-latest |
| 67 | + |
| 68 | + permissions: |
| 69 | + contents: read |
| 70 | + |
| 71 | + steps: |
| 72 | + - name: Checkout Repository |
| 73 | + uses: actions/checkout@v4 |
| 74 | + |
| 75 | + - name: Deploy System |
| 76 | + id: deploy-system |
| 77 | + uses: ./.github/actions/deploy-docker-images |
| 78 | + with: |
| 79 | + environment: acceptance |
| 80 | + version: latest |
| 81 | + image-urls: ${{ needs.find-latest-images.outputs.image-digest-urls }} |
| 82 | + |
| 83 | + - name: Setup Java |
| 84 | + uses: actions/setup-java@v4 |
| 85 | + with: |
| 86 | + java-version: 25 |
| 87 | + distribution: temurin |
| 88 | + |
| 89 | + - name: Setup Gradle |
| 90 | + uses: gradle/actions/setup-gradle@v4 |
| 91 | + |
| 92 | + - name: Make Gradle Wrapper executable |
| 93 | + run: chmod +x ./gradlew |
| 94 | + working-directory: system-test |
| 95 | + |
| 96 | + - name: Run Acceptance Tests |
| 97 | + run: echo "Run Acceptance Tests" |
| 98 | + |
| 99 | + - name: Run External System Contract Tests |
| 100 | + run: echo "Run External System Contract Tests" |
| 101 | + |
| 102 | + - name: Run E2E Tests |
| 103 | + run: ./gradlew test --tests com.optivem.atddaccelerator.template.systemtest.e2etests.* |
| 104 | + working-directory: system-test |
| 105 | + |
| 106 | + prerelease: |
| 107 | + needs: [find-latest-images, should-run, system-test] |
| 108 | + if: needs.system-test.result == 'success' |
| 109 | + runs-on: ubuntu-latest |
| 110 | + outputs: |
| 111 | + version: ${{ steps.generate-version.outputs.version }} |
| 112 | + image-urls: ${{ steps.tag-images.outputs.image-urls }} |
| 113 | + |
| 114 | + permissions: |
| 115 | + contents: write |
| 116 | + packages: write |
| 117 | + |
| 118 | + steps: |
| 119 | + - name: Checkout Repository |
| 120 | + uses: actions/checkout@v4 |
| 121 | + with: |
| 122 | + fetch-depth: 0 # Fetch all history and tags |
| 123 | + |
| 124 | + - name: Generate Prerelease Version |
| 125 | + id: generate-version |
| 126 | + uses: optivem/generate-prerelease-version-action@v1 |
| 127 | + |
| 128 | + - name: Tag Docker Images for Prerelease |
| 129 | + id: tag-images |
| 130 | + uses: optivem/tag-docker-images-action@v1 |
| 131 | + with: |
| 132 | + image-urls: ${{ needs.find-latest-images.outputs.image-digest-urls }} |
| 133 | + tag: ${{ steps.generate-version.outputs.version }} |
| 134 | + env: |
| 135 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 136 | + |
| 137 | + - name: Create Prerelease |
| 138 | + id: create-release |
| 139 | + uses: optivem/create-release-action@v1 |
| 140 | + with: |
| 141 | + base-version: latest |
| 142 | + release-version: ${{ steps.generate-version.outputs.version }} |
| 143 | + environment: acceptance |
| 144 | + status: prerelease |
| 145 | + artifact-urls: ${{ steps.tag-images.outputs.image-urls }} |
| 146 | + is-prerelease: true |
| 147 | + env: |
| 148 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 149 | + |
| 150 | + summary: |
| 151 | + needs: [find-latest-images, should-run, prerelease, system-test] |
| 152 | + if: always() # Run even if previous jobs fail |
| 153 | + runs-on: ubuntu-latest |
| 154 | + |
| 155 | + steps: |
| 156 | + - name: Checkout Repository |
| 157 | + uses: actions/checkout@v4 |
| 158 | + |
| 159 | + - name: Acceptance Stage Summary |
| 160 | + uses: optivem/summarize-system-stage-action@v1 |
| 161 | + with: |
| 162 | + stage-name: 'Acceptance Stage' |
| 163 | + environment: acceptance |
| 164 | + stage-result: ${{ needs.prerelease.result }} |
| 165 | + success-version: ${{ needs.prerelease.outputs.version }} |
| 166 | + success-artifact-ids: ${{ needs.prerelease.outputs.image-urls }} |
0 commit comments