No logs before upload #5
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: Complexity level 6 -> Run Tests | |
on: | |
schedule: | |
- cron: "0 8 * * *" # run on schedule, examples: https://crontab.guru/examples.html | |
pull_request: | |
workflow_dispatch: | |
inputs: | |
environment: | |
type: choice | |
description: "Environment: localhost / dev" | |
required: true | |
options: | |
- localhost | |
- dev | |
default: "localhost" | |
browser: | |
type: choice | |
description: "Browser: chrome / firefox" | |
required: true | |
options: | |
- chrome | |
- firefox | |
default: "chrome" | |
jobs: | |
build-packages: | |
name: Build packages & app | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Install Node.js | |
if: ${{ inputs.environment == 'localhost' || github.event_name == 'pull_request' }} | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ">=16.0.0" | |
- name: Build packages | |
if: ${{ inputs.environment == 'localhost' || github.event_name == 'pull_request' }} | |
run: yarn | |
- name: Build application | |
if: ${{ inputs.environment == 'localhost' || github.event_name == 'pull_request' }} | |
run: yarn build-localhost | |
- name: Save build folder | |
if: ${{ inputs.environment == 'localhost' || github.event_name == 'pull_request' }} | |
uses: actions/upload-artifact@v3 | |
with: | |
name: build | |
if-no-files-found: error | |
path: build | |
- name: Logs from build folder | |
if: always() | |
run: | | |
echo "--<< LOCAL APP FRROM BUILD STEP >>--" | |
ls -lh ${{ github.workspace }}/build | |
run-specs: | |
name: Run Tests | |
needs: [build-packages] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Install Node.js | |
if: ${{ inputs.environment == 'localhost' || github.event_name == 'pull_request' }} | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ">=16.0.0" | |
- name: Download the build folders | |
if: ${{ inputs.environment == 'localhost' || github.event_name == 'pull_request' }} | |
uses: actions/download-artifact@v3 | |
with: | |
name: build | |
path: build | |
- name: Install Serve | |
if: ${{ inputs.environment == 'localhost' || github.event_name == 'pull_request' }} | |
run: yarn global add serve | |
- name: Run application on localhost | |
if: ${{ inputs.environment == 'localhost' || github.event_name == 'pull_request' }} | |
run: serve -s ${{ github.workspace }}/build & | |
- name: Run Tests on LOCALHOST | |
if: ${{ inputs.environment == 'localhost' || github.event_name == 'pull_request' }} | |
uses: cypress-io/github-action@v6 | |
with: | |
install: true | |
wait-on: "http://localhost:3000" | |
wait-on-timeout: 120 | |
browser: ${{ inputs.browser }} | |
config-file: /${{ github.workspace }}/cypress/configs/cypress.localhost.config.js | |
- name: Run Tests on DEV | |
if: ${{ github.event_name == 'schedule' || inputs.environment != 'localhost' && github.event_name != 'pull_request' }} | |
uses: cypress-io/github-action@v6 | |
with: | |
install: true | |
browser: ${{ inputs.browser }} | |
config-file: /${{ github.workspace }}/cypress/configs/cypress.dev.config.js | |
- name: Cypress screenshots | |
uses: actions/upload-artifact@v2 | |
if: failure() | |
with: | |
name: cypress-screenshots | |
path: ${{ github.workspace }}/cypress/screenshots | |
- name: Cypress videos | |
uses: actions/upload-artifact@v2 | |
if: always() | |
with: | |
name: cypress-videos | |
path: ${{ github.workspace }}/cypress/videos | |
- name: Logs from the run | |
if: always() | |
run: | | |
echo "--<< BRANCH_NAME >>--" | |
export BRANCH_NAME=${GITHUB_REF#refs/heads/} | |
echo "--<< GITHUB ACTION RUN URL >>--" | |
export RUN_URL=${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} | |
echo "--<< WORKFLOW TRIGGER EVENT NAME >>--" | |
echo ${{ github.event_name }} | |
echo "--<< SELECTED ENVIRONMENT >>--" | |
echo ${{ inputs.environment }} | |
echo "--<< SELECTED BROWSER >>--" | |
echo ${{ inputs.browser }} | |
echo "--<< CYPRESS CONFIG LOCALHOST >>--" | |
cat ${{ github.workspace }}/cypress/configs/cypress.localhost.config.js | |
echo "--<< CYPRESS CONFIG DEV >>--" | |
cat ${{ github.workspace }}/cypress/configs/cypress.dev.config.js | |
echo "--<< LOCAL APP FRROM BUILD STEP >>--" | |
ls -lh ${{ github.workspace }}/build | |
report: | |
name: Report result | |
needs: [run-specs] | |
if: always() | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout the repository | |
if: always() | |
uses: actions/checkout@v3 | |
- name: Install Node.js | |
if: always() | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ">=16.0.0" | |
- name: Install dependency | |
if: always() | |
run: | | |
yarn add isomorphic-fetch | |
- name: Slack (${{ needs.run-specs.result }}) notification | |
if: always() | |
run: | | |
export SCRIPT_PATH=${{ github.workspace }}/slack/${{ needs.run-specs.result == 'success' && 'success_message.js' || 'failed_message.js'}} | |
export EVENT_NAME=${{ github.event_name }} | |
export ENVIRONMENT=${{ inputs.environment }} | |
export BRANCH_NAME=${GITHUB_REF#refs/heads/} | |
export RUN_URL=${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} | |
yarn node $SCRIPT_PATH "${{ secrets.SLACK_WEBHOOK }}" "$EVENT_NAME" "$BRANCH_NAME" "$RUN_URL" "$ENVIRONMENT" |