Skip to content

Commit 4af82cc

Browse files
committed
feat: devtest with PR number and testing
1 parent c98c455 commit 4af82cc

3 files changed

Lines changed: 46 additions & 60 deletions

File tree

.github/workflows/cicd-1-pull-request-devtest.yaml

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -86,39 +86,39 @@ jobs:
8686
python_version: "${{ needs.metadata.outputs.python_version }}"
8787
terraform_version: "${{ needs.metadata.outputs.terraform_version }}"
8888
version: "${{ needs.metadata.outputs.version }}"
89-
# test-stage: # Recommended maximum execution time is 5 minutes
90-
# name: 'Test stage'
91-
# needs: [metadata]
92-
# uses: ./.github/workflows/stage-2-test.yaml
93-
# with:
94-
# unit_test_dir: tests/UnitTests
95-
# app_dir: application/CohortManager
96-
# build_datetime: '${{ needs.metadata.outputs.build_datetime }}'
97-
# build_timestamp: '${{ needs.metadata.outputs.build_timestamp }}'
98-
# build_epoch: '${{ needs.metadata.outputs.build_epoch }}'
99-
# nodejs_version: '${{ needs.metadata.outputs.nodejs_version }}'
100-
# python_version: '${{ needs.metadata.outputs.python_version }}'
101-
# terraform_version: '${{ needs.metadata.outputs.terraform_version }}'
102-
# version: '${{ needs.metadata.outputs.version }}'
103-
# secrets: inherit
104-
# analysis-stage: # Recommended maximum execution time is 5 minutes
105-
# name: "Analysis stage"
106-
# needs: [metadata, commit-stage, test-stage]
107-
# uses: ./.github/workflows/stage-2-analyse.yaml
108-
# secrets:
109-
# sonar_token: ${{ secrets.SONAR_TOKEN }}
110-
# with:
111-
# unit_test_dir: tests/UnitTests
112-
# build_datetime: "${{ needs.metadata.outputs.build_datetime }}"
113-
# build_timestamp: "${{ needs.metadata.outputs.build_timestamp }}"
114-
# build_epoch: "${{ needs.metadata.outputs.build_epoch }}"
115-
# nodejs_version: "${{ needs.metadata.outputs.nodejs_version }}"
116-
# python_version: "${{ needs.metadata.outputs.python_version }}"
117-
# terraform_version: "${{ needs.metadata.outputs.terraform_version }}"
118-
# version: "${{ needs.metadata.outputs.version }}"
89+
test-stage: # Recommended maximum execution time is 5 minutes
90+
name: 'Test stage'
91+
needs: [metadata]
92+
uses: ./.github/workflows/stage-2-test.yaml
93+
with:
94+
unit_test_dir: tests/UnitTests
95+
app_dir: application/CohortManager
96+
build_datetime: '${{ needs.metadata.outputs.build_datetime }}'
97+
build_timestamp: '${{ needs.metadata.outputs.build_timestamp }}'
98+
build_epoch: '${{ needs.metadata.outputs.build_epoch }}'
99+
nodejs_version: '${{ needs.metadata.outputs.nodejs_version }}'
100+
python_version: '${{ needs.metadata.outputs.python_version }}'
101+
terraform_version: '${{ needs.metadata.outputs.terraform_version }}'
102+
version: '${{ needs.metadata.outputs.version }}'
103+
secrets: inherit
104+
analysis-stage: # Recommended maximum execution time is 5 minutes
105+
name: "Analysis stage"
106+
needs: [metadata, commit-stage, test-stage]
107+
uses: ./.github/workflows/stage-2-analyse.yaml
108+
secrets:
109+
sonar_token: ${{ secrets.SONAR_TOKEN }}
110+
with:
111+
unit_test_dir: tests/UnitTests
112+
build_datetime: "${{ needs.metadata.outputs.build_datetime }}"
113+
build_timestamp: "${{ needs.metadata.outputs.build_timestamp }}"
114+
build_epoch: "${{ needs.metadata.outputs.build_epoch }}"
115+
nodejs_version: "${{ needs.metadata.outputs.nodejs_version }}"
116+
python_version: "${{ needs.metadata.outputs.python_version }}"
117+
terraform_version: "${{ needs.metadata.outputs.terraform_version }}"
118+
version: "${{ needs.metadata.outputs.version }}"
119119
build-image-stage: # Recommended maximum execution time is 3 minutes
120120
name: "Image build stage"
121-
needs: [metadata] #commit-stage, test-stage, analysis-stage]
121+
needs: [metadata, test-stage, analysis-stage]
122122
uses: ./.github/workflows/stage-3-build-images-devtest.yaml
123123
secrets:
124124
client_id: ${{ secrets.AZURE_CLIENT_ID }}
@@ -132,19 +132,19 @@ jobs:
132132
function_app_source_code_path: application/CohortManager/src
133133
project_name: cohort-manager
134134
build_all_images: true
135-
# acceptance-stage: # Recommended maximum execution time is 10 minutes
136-
# name: "Acceptance stage"
137-
# needs: [metadata, build-image-stage]
138-
# uses: ./.github/workflows/stage-4-acceptance.yaml
139-
# if: needs.metadata.outputs.does_pull_request_exist == 'true' || (github.event_name == 'pull_request' && (github.event.action == 'opened' || github.event.action == 'reopened'))
140-
# with:
141-
# build_datetime: "${{ needs.metadata.outputs.build_datetime }}"
142-
# build_timestamp: "${{ needs.metadata.outputs.build_timestamp }}"
143-
# build_epoch: "${{ needs.metadata.outputs.build_epoch }}"
144-
# nodejs_version: "${{ needs.metadata.outputs.nodejs_version }}"
145-
# python_version: "${{ needs.metadata.outputs.python_version }}"
146-
# terraform_version: "${{ needs.metadata.outputs.terraform_version }}"
147-
# version: "${{ needs.metadata.outputs.version }}"
135+
acceptance-stage: # Recommended maximum execution time is 10 minutes
136+
name: "Acceptance stage"
137+
needs: [metadata, build-image-stage]
138+
uses: ./.github/workflows/stage-4-acceptance.yaml
139+
if: needs.metadata.outputs.does_pull_request_exist == 'true' || (github.event_name == 'pull_request' && (github.event.action == 'opened' || github.event.action == 'reopened'))
140+
with:
141+
build_datetime: "${{ needs.metadata.outputs.build_datetime }}"
142+
build_timestamp: "${{ needs.metadata.outputs.build_timestamp }}"
143+
build_epoch: "${{ needs.metadata.outputs.build_epoch }}"
144+
nodejs_version: "${{ needs.metadata.outputs.nodejs_version }}"
145+
python_version: "${{ needs.metadata.outputs.python_version }}"
146+
terraform_version: "${{ needs.metadata.outputs.terraform_version }}"
147+
version: "${{ needs.metadata.outputs.version }}"
148148
deploy-stage:
149149
if: github.event_name == 'push'
150150
name: Deploy DevTest environment for commit ${{ github.sha }}

.github/workflows/stage-3-build-images-devtest.yaml

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ jobs:
9090
if: needs.get-functions.outputs.FUNC_NAMES != '[]'
9191
outputs:
9292
short_commit_hash: ${{ env.COMMIT_HASH_TAG }}
93-
devtest_commit_hash: ${{ env.DEVTEST_HASH_TAG }}
9493
devtest_pr_num_tag: ${{ env.DEVTEST_PR_NUM_TAG }}
9594
steps:
9695
- uses: actions/checkout@v4
@@ -130,18 +129,11 @@ jobs:
130129
PR_NUM_TAG="pr${PR_NUM}"
131130
132131
DEVTEST_PR_NUM_TAG="devtest_${PR_NUM_TAG}"
133-
echo "PR Number tag: ${PR_NUM_TAG}"
134-
echo "Devtest Pr Num tag: ${DEVTEST_PR_NUM_TAG}"
135132
echo "DEVTEST_PR_NUM_TAG=${DEVTEST_PR_NUM_TAG}" >> ${GITHUB_ENV}
136133
137134
SHORT_COMMIT_HASH=$(git rev-parse --short ${GITHUB_SHA})
138-
echo "Commit hash tag: ${SHORT_COMMIT_HASH}"
139135
echo "COMMIT_HASH_TAG=${SHORT_COMMIT_HASH}" >> ${GITHUB_ENV}
140136
141-
# DEVTEST_COMMIT_HASH="devtest_${SHORT_COMMIT_HASH}"
142-
# echo "Commit devtest hash tag: ${DEVTEST_COMMIT_HASH}"
143-
# echo "DEVTEST_HASH_TAG=${DEVTEST_COMMIT_HASH}" >> ${GITHUB_ENV}
144-
145137
echo "ENVIRONMENT_TAG=${ENVIRONMENT_TAG}" >> ${GITHUB_ENV}
146138
147139
- name: Build and Push Image
@@ -169,9 +161,7 @@ jobs:
169161
170162
# Tag the image
171163
echo "Tag the image:"
172-
#docker tag ${PROJECT_NAME}-${function}:latest "$repo_name:${DEVTEST_HASH_TAG}"
173164
docker tag ${PROJECT_NAME}-${function}:latest "$repo_name:${DEVTEST_PR_NUM_TAG}"
174-
# docker tag ${PROJECT_NAME}-${function}:latest "$repo_name:${ENVIRONMENT_TAG}"
175165
176166
# If this variable is set, the create-sbom-report.sh script will scan this docker image instead.
177167
export CHECK_DOCKER_IMAGE=${PROJECT_NAME}-${function}:latest
@@ -189,7 +179,5 @@ jobs:
189179
repo_name="${ACR_NAME}.azurecr.io/${PROJECT_NAME}-${function}"
190180
191181
# Remove the images
192-
# docker rmi "${repo_name}:${DEVTEST_HASH_TAG}"
193182
docker rmi "${repo_name}:${DEVTEST_PR_NUM_TAG}"
194-
# docker rmi "${repo_name}:${ENVIRONMENT_TAG}"
195183
docker rmi ${PROJECT_NAME}-${function}:latest

.github/workflows/stage-4-deploy-devtest.yaml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,17 +94,15 @@ jobs:
9494
9595
# Define which tests to run based on the environment
9696
declare -A test_types=(
97-
["development"]=""
97+
["development"]="smoke_e2e"
9898
)
9999
100100
# Derive the short SHA from the provided commit
101101
git_short_sha=$(git rev-parse --short "$COMMIT_SHA")
102-
devtest_short_sha="devtest_${git_short_sha}"
103102
104103
# Get the PR Number tag
105104
PR_NUM=$(gh api repos/${{ github.repository }}/commits/${{ github.sha }}/pulls --jq '.[0].number')
106-
PR_NUM_TAG="pr${PR_NUM}"
107-
DEVTEST_PR_NUM_TAG="devtest_${PR_NUM_TAG}"
105+
DEVTEST_PR_NUM_TAG="devtest_pr${PR_NUM}"
108106
echo "Devtest_PR_Num_tag: ${DEVTEST_PR_NUM_TAG}"
109107
110108
# Prepare parameters as separate key=value tokens

0 commit comments

Comments
 (0)