Performance Tests #37
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Performance Tests | |
on: | |
schedule: | |
- cron: '00 08 25 * *' | |
workflow_dispatch: | |
inputs: | |
environment: | |
required: true | |
type: choice | |
description: Select the Environment | |
options: | |
- dev | |
- uat | |
default: dev | |
type: | |
required: true | |
type: choice | |
description: Select the test type | |
options: | |
- smoke | |
- constant | |
default: smoke | |
positions-per-file: | |
required: true | |
type: number | |
description: The number of debt positions each test file will contain | |
default: 1 | |
file-number: | |
required: true | |
type: number | |
description: The number of test file | |
default: 1 | |
lifetime: | |
required: true | |
type: number | |
description: The max expected duration to complete the test | |
default: 1 | |
canary: | |
description: 'run the tests on canary version' | |
required: false | |
type: boolean | |
default: false | |
permissions: | |
id-token: write | |
contents: read | |
deployments: write | |
jobs: | |
performance_test: | |
name: Test ${{(github.event.inputs == null && 'dev') || inputs.environment }} | |
runs-on: ubuntu-latest | |
environment: ${{(github.event.inputs == null && 'dev') || inputs.environment }} | |
steps: | |
- name: Checkout | |
id: checkout | |
uses: actions/checkout@1f9a0c22da41e6ebfa534300ef656657ea2c6707 | |
- name: Prepare performance data | |
shell: bash | |
run: | | |
cd ./performance-test | |
chmod +x ./prepare_performance_data.sh | |
./prepare_performance_data.sh ${{inputs.file-number}} ${{inputs.positions-per-file}} | |
export BASE_PATH=./src/test-types | |
jq '.scenarios.contacts.timeUnit |= "${{inputs.lifetime}}m" | .scenarios.contacts.duration |= "${{inputs.lifetime}}m"' ${BASE_PATH}/${{inputs.type}}.json > temp.json && mv temp.json ${BASE_PATH}/${{inputs.type}}.json | |
- name: Run k6 local test | |
uses: grafana/k6-action@e4714b734f2b0afaabeb7b4a69142745548ab9ec # v0.3.1 | |
with: | |
filename: performance-test/src/main_scenario.js | |
flags: --env VARS=environments/${{inputs.environment}}.environment.json --env TEST_TYPE=./test-types/${{inputs.type}}.json | |
env: | |
API_SUBSCRIPTION_KEY: ${{ secrets.SUBKEY }} | |
FILE_NUMBER: ${{inputs.file-number}} | |
delete_github_deployments: | |
runs-on: ubuntu-latest | |
needs: performance_test | |
if: ${{ always() }} | |
steps: | |
- name: Delete Previous deployments | |
uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410 # v6 | |
env: | |
SHA_HEAD: ${{ (github.event_name == 'pull_request' && github.event.pull_request.head.sha) || github.sha}} | |
with: | |
script: | | |
const { SHA_HEAD } = process.env | |
const deployments = await github.rest.repos.listDeployments({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
sha: SHA_HEAD | |
}); | |
await Promise.all( | |
deployments.data.map(async (deployment) => { | |
await github.rest.repos.createDeploymentStatus({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
deployment_id: deployment.id, | |
state: 'inactive' | |
}); | |
return github.rest.repos.deleteDeployment({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
deployment_id: deployment.id | |
}); | |
}) | |
); |