Integration tests in stage #345
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: Integration tests in stage | |
# Controls when the action will run. | |
on: | |
# Allow the workflow to be reusable | |
workflow_call: | |
# Allow the workflow to be manually triggered | |
workflow_dispatch: | |
# Allow the workflow to be automatically triggered everyday at 3 am | |
schedule: | |
- cron: '0 3 * * *' | |
env: | |
GH_PAGES_ENDPOINT: 'https://graasp.github.io/graasp-deploy/' | |
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | |
jobs: | |
smoke-test: | |
name: Smoke Test | |
# The type of runner that the job will run on | |
runs-on: ubuntu-latest | |
# Steps represent a sequence of tasks that will be executed as part of the job | |
steps: | |
- id: set-date | |
run: | | |
DATE=$(echo "`date +"%Y-%m-%d-%H-%M"`") | |
echo "DATE=$DATE" >> $GITHUB_ENV | |
# Check-out repository under $GITHUB_WORKSPACE, so the job can access it | |
- name: Git checkout | |
uses: actions/checkout@v3 | |
# Download and cache distribution of the requested Node.js version, and add it to the PATH | |
- name: Setup node | |
id: setup-node | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '16' | |
check-latest: true | |
# Setup the runner with the appropriate packages | |
- name: Setup runner | |
id: setup-runner | |
run: | | |
npm install newman newman-reporter-htmlextra | |
# Run a set of commands using the runners shell to perform tests | |
- name: Run newman | |
id: newman | |
run: | | |
FILE_NAME=$(echo $DATE-smoke-test-run.html) | |
echo "FILE_NAME=$FILE_NAME" >> $GITHUB_ENV | |
node_modules/newman/bin/newman.js run postman/GraaspSmokeTest.postman_collection.json -r htmlextra --reporter-htmlextra-export ./newman/smoke-test/$FILE_NAME | |
- name: Generate job summary markdown | |
env: | |
FILE_NAME: ${{ env.FILE_NAME }} | |
if: always() | |
run: | | |
echo '[See smoke test summary in github pages](${{env.GH_PAGES_ENDPOINT}}newman/smoke-test/${{ env.FILE_NAME }})' >> $GITHUB_STEP_SUMMARY | |
echo 'Please wait for the github pages deployment to finish (this can take around 2 minutes).' >> $GITHUB_STEP_SUMMARY | |
- name: Commit step | |
id: commit | |
if: always() | |
uses: stefanzweifel/git-auto-commit-action@v4 | |
with: | |
commit_message: 'chore(test): Smoke test run ${{ env.DATE }}' | |
branch: gh-pages | |
file_pattern: newman/* | |
api-test: | |
name: Graasp API Test | |
runs-on: ubuntu-latest | |
env: | |
PASSWORD: ${{ secrets.STAGING_PASSWORD }} | |
EMAIL: ${{ secrets.STAGING_EMAIL }} | |
API_HOST: ${{ secrets.REACT_APP_API_HOST_STAGE }} | |
# Steps represent a sequence of tasks that will be executed as part of the job | |
steps: | |
- id: set-date | |
run: | | |
DATE=$(echo "`date +"%Y-%m-%d-%H-%M"`") | |
echo "DATE=$DATE" >> $GITHUB_ENV | |
- name: Git checkout | |
uses: actions/checkout@v3 | |
- name: Setup node | |
id: setup-node | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '16' | |
check-latest: true | |
- name: Setup runner | |
id: setup-runner | |
run: | | |
npm install newman newman-reporter-htmlextra | |
# Set environment variables required to perform the tests | |
- name: Setup environment secrets | |
id: setup-secrets | |
run: | | |
cat postman/postman_environment.json | jq -r --arg password "$PASSWORD" --arg email "$EMAIL" --arg api_host "$API_HOST" \ | |
'.values[0].value |= $password | .values[1].value|= $email | .values[2].value|= $api_host' > postman/staging.postman_environment.json | |
# Run a set of commands using the runners shell to perform tests | |
- name: Run newman | |
id: newman | |
run: | | |
FILE_NAME=$(echo "`date +"%Y-%m-%d-%H-%M"`"-run.html) | |
echo "FILE_NAME=$FILE_NAME" >> $GITHUB_ENV | |
node_modules/newman/bin/newman.js run postman/GraaspAPITest.postman_collection.json -e postman/staging.postman_environment.json -r htmlextra --reporter-htmlextra-export ./newman/api-test/$FILE_NAME | |
- name: Generate job summary markdown | |
env: | |
FILE_NAME: ${{ env.FILE_NAME }} | |
if: always() | |
run: | | |
echo '[See summary in github pages](${{env.GH_PAGES_ENDPOINT}}newman/api-test/${{ env.FILE_NAME }})' >> $GITHUB_STEP_SUMMARY | |
echo 'Please wait for the github pages deployment to finish (this can take around 2 minutes).' >> $GITHUB_STEP_SUMMARY | |
- name: Commit step | |
id: commit | |
if: always() | |
uses: stefanzweifel/git-auto-commit-action@v4 | |
with: | |
commit_message: 'chore(test): run API tests ${{ env.DATE }}' | |
branch: gh-pages | |
file_pattern: newman/* |