revert portal dockerfile to node 16 #275
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: Build and Deploy Cypress and Execute Tests | |
on: | |
push: | |
branches: ['test', 'cypress*'] | |
env: | |
DASHBOARD_PROJECT_ID: ${{ secrets.CY_DASHBOARD_PRJ_ID }} | |
DASHBOARD_RECORD_KEY: ${{ secrets.CY_DASHBOARD_RECORD_KEY }} | |
EXECUTION_ENV: prod | |
GIT_COMMIT_BRANCH: ${{ github.ref_name }} | |
GIT_COMMIT_SHA: ${{ github.sha }} | |
GIT_COMMIT_AUTHOR: ${{ github.actor }} | |
GIT_COMMIT_MESSAGE: ${{ github.event.head_commit.message }} | |
GIT_REPO_URL: ${{ github.repository }} | |
jobs: | |
cypress-run: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Build GWA API Image | |
run: | | |
git clone https://github.com/bcgov/gwa-api.git | |
cd gwa-api/microservices/gatewayApi | |
docker build -t gwa-api:e2e . | |
- name: Checkout Portal | |
uses: actions/checkout@v2 | |
- name: Determine Download file name | |
id: set_variable | |
run: | | |
echo ${{ runner.arch }} | |
if [ "${{ runner.arch }}" == "X64" ]; then | |
echo "::set-output name=my_variable::gwa_Linux_x86_64.tgz" | |
elif [ "${{ runner.arch }}" == "ARM64" ]; then | |
echo "::set-output name=my_variable::gwa_Linux_arm64.tgz" | |
else | |
echo "unsupported architecture" | |
fi | |
- name: Download Binar | |
uses: robinraju/release-downloader@v1.8 | |
with: | |
repository: "bcgov/gwa-cli" | |
latest: true | |
fileName: ${{ steps.set_variable.outputs.my_variable }} | |
out-file-path: "${{ github.workspace }}/e2e" | |
- name: Unzip file | |
run: | | |
cd ${{ github.workspace }}/e2e | |
tar xvzf ${{ steps.set_variable.outputs.my_variable }} | |
- name: Build Docker Images | |
run: | | |
docker-compose build | |
- name: Spin up API Services Portal and Run E2E Tests | |
run: | | |
export CY_EXECUTION_ENV=${{ env.EXECUTION_ENV }} | |
export CY_RECORD_KEY=${{ env.DASHBOARD_RECORD_KEY }} | |
export CY_PROJECT_ID=${{ env.DASHBOARD_PROJECT_ID }} | |
export CY_COMMIT_BRANCH=${{ env.GIT_COMMIT_BRANCH }} | |
export CY_COMMIT_SHA=${{ env.GIT_COMMIT_SHA }} | |
export CY_COMMIT_AUTHOR=${{ env.GIT_COMMIT_AUTHOR }} | |
export CY_COMMIT_MESSAGE="${{ env.GIT_COMMIT_MESSAGE }}" | |
export CY_REPO_URL=${{ env.GIT_REPO_URL }} | |
export CY_COMMIT_AUTHOR_EMAIL=$(git --no-pager show -s --format='%ae' ${{ env.GIT_COMMIT_SHA }}) | |
docker-compose up -d | |
- name: Execute Tests & Clean Up | |
run: | | |
while true; do | |
if [ "$(docker ps -aq -f status=exited -f name=cypress-e2e)" ]; then | |
# cleanup | |
docker-compose down | |
break | |
else | |
echo "Waiting for Cypress to Complete E2E Tests....." | |
sleep 1m | |
fi | |
done | |
- name: Upload E2E Test Results Report | |
uses: actions/upload-artifact@v2 | |
with: | |
name: test-results | |
path: ${{ github.workspace }}/e2e/results/report | |
- name: SonarCloud Scan | |
uses: sonarsource/sonarcloud-github-action@master | |
with: | |
args: > | |
-Dsonar.organization=bcgov-oss | |
-Dsonar.projectKey=aps-portal-e2e | |
-Dsonar.host.url=https://sonarcloud.io | |
-Dsonar.sources=src/nextapp | |
-Dsonar.javascript.lcov.reportPaths=./e2e/coverage/lcov.info | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
- name: Check for failed tests and create Issue | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
FAILURE_COUNT=$(cat ${{ github.workspace }}/e2e/results/bcgov-aps-e2e-report.json | jq '.stats.failures') | |
if [[ "$FAILURE_COUNT" -gt 0 ]]; then | |
FAILED_TESTS=$(cat ${{ github.workspace }}/e2e/results/bcgov-aps-e2e-report.json | jq '.results | .[] | .suites | .[].tests | .[] | select(.fail==true) | .title') | |
STATS=$(cat ${{ github.workspace }}/e2e/results/bcgov-aps-e2e-report.json | jq '.stats') | |
echo -e "Stats: $STATS\n\nFailed Tests:\n$FAILED_TESTS\n\nRun Link: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" > msg | |
export MSG=$(cat msg) | |
gh issue create --title "FAILED: Automated Tests($FAILURE_COUNT)" --body "$MSG" --label "automation" --assignee "${{ env.GIT_COMMIT_AUTHOR }}" | |
fi |