Build and run tests on PR #365
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 run tests on PR | |
on: | |
pull_request: | |
workflow_dispatch: | |
jobs: | |
build-and-run-tests: | |
runs-on: ubuntu-latest | |
environment: dev | |
steps: | |
- name: Install Node | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '16' | |
- name: Checkout merged code | |
uses: actions/checkout@v2 | |
- name: Retrieve npm cache | |
uses: actions/cache@v2 | |
with: | |
path: | | |
~/.npm | |
/home/runner/.cache/firebase/emulators | |
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-node- | |
- name: Bootstrap | |
run: npm run bootstrap | |
- name: Build project | |
run: npm run build | |
env: | |
REACT_APP_FIREBASE_CONFIG_API_KEY: ${{ secrets.REACT_APP_FIREBASE_CONFIG_API_KEY }} | |
REACT_APP_FIREBASE_CONFIG_AUTH_DOMAIN: ${{ secrets.REACT_APP_FIREBASE_CONFIG_AUTH_DOMAIN }} | |
REACT_APP_FIREBASE_CONFIG_DATABASE_URL: ${{ secrets.REACT_APP_FIREBASE_CONFIG_DATABASE_URL }} | |
REACT_APP_FIREBASE_CONFIG_PROJECT_ID: ${{ secrets.REACT_APP_FIREBASE_CONFIG_PROJECT_ID }} | |
REACT_APP_FIREBASE_CONFIG_STORAGE_BUCKET: ${{ secrets.REACT_APP_FIREBASE_CONFIG_STORAGE_BUCKET }} | |
REACT_APP_FIREBASE_CONFIG_MESSAGING_SENDER_ID: ${{ secrets.REACT_APP_FIREBASE_CONFIG_MESSAGING_SENDER_ID }} | |
REACT_APP_FIREBASE_CONFIG_APP_ID: ${{ secrets.REACT_APP_FIREBASE_CONFIG_APP_ID }} | |
REACT_APP_FIREBASE_USE_EMULATORS: true | |
REACT_APP_ENV: dev | |
- name: Lint functions | |
run: npm --prefix packages/functions run lint | |
- name: Start emulators | |
run: npx firebase emulators:start & | |
env: | |
FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }} | |
- name: Sleep for 30 seconds | |
run: sleep 30s | |
shell: bash | |
- name: Load initial data | |
run: npm run scripts:load-initial-data | |
env: | |
FIRESTORE_EMULATOR_HOST: localhost:8080 | |
GCLOUD_PROJECT: ${{ secrets.REACT_APP_FIREBASE_CONFIG_PROJECT_ID }} | |
FIREBASE_DATABASE_EMULATOR_HOST: localhost:9000 | |
- name: Firestore rules test | |
run: npm run test:firestore | |
env: | |
FIRESTORE_EMULATOR_HOST: localhost:8080 | |
- name: Database rules test | |
run: npm run test:database | |
env: | |
FIREBASE_DATABASE_EMULATOR_HOST: localhost:9000 | |
- name: Firestore run functions test | |
run: npm run test:functions | |
env: | |
FIRESTORE_EMULATOR_HOST: localhost:8080 | |
GCLOUD_PROJECT: ${{ secrets.REACT_APP_FIREBASE_CONFIG_PROJECT_ID }} | |
FIREBASE_DATABASE_EMULATOR_HOST: localhost:9000 | |
- name: Run e2e test | |
uses: cypress-io/github-action@v2 | |
with: | |
working-directory: packages/game-app | |
install: false | |
wait-on: 'http://localhost:5000' | |
browser: chrome | |
env: | |
CYPRESS_BASE_URL: http://localhost:5000 | |
FIREBASE_AUTH_EMULATOR_HOST: localhost:9099 | |
FIRESTORE_EMULATOR_HOST: localhost:8080 | |
REACT_APP_FIREBASE_CONFIG_PROJECT_ID: ${{ secrets.REACT_APP_FIREBASE_CONFIG_PROJECT_ID }} | |
- name: Upload test videos on fail | |
uses: actions/upload-artifact@v4 | |
if: failure() | |
with: | |
name: cypress-videos | |
path: packages/game-app/cypress/videos | |
- name: Create BOM | |
run: npm run bom | |
- name: Upload BOM to Dependency-Track | |
uses: DependencyTrack/gh-upload-sbom@v3 | |
with: | |
serverHostname: 'https://dtrack.dev.eficode.io/' | |
apiKey: ${{ secrets.DEPENDENCYTRACK_APIKEY }} | |
projectName: 'Pipeline_game' | |
projectVersion: 'main' | |
bomFilename: "$DIR/bom.xml" | |
autoCreate: true | |