From 509bd2ae87838120ed54973a90f9b7d2de152118 Mon Sep 17 00:00:00 2001 From: Aleksandr Chernigin Date: Mon, 19 Feb 2024 20:36:43 +0400 Subject: [PATCH] Setup CI/CD for lint, vitest and cypress tests --- .github/workflows/build.yml | 47 ++++++++++++++ .github/workflows/{main.yml => e2e-tests.yml} | 64 +------------------ 2 files changed, 49 insertions(+), 62 deletions(-) create mode 100644 .github/workflows/build.yml rename .github/workflows/{main.yml => e2e-tests.yml} (66%) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..ae17a39 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,47 @@ +name: Build + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + container: + image: cypress/browsers:node-18.16.0-chrome-114.0.5735.133-1-ff-114.0.2-edge-114.0.1823.51-1 + options: --user 1001 + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Cache node_modules + uses: actions/setup-node@v4 + with: + node-version: 18 + cache: 'npm' + + - name: Cypress install + uses: cypress-io/github-action@v6 + with: + runTests: false + + - name: Write Firebase config + run: | + echo ${{ secrets.FIREBASE_CONFIG }} | base64 -d > firebase.config.json + + - run: npx cypress info + - run: node --version + - run: node -p 'os.cpus()' + - run: npm run lint + - run: npm run test:ci + - run: npm run build + + - name: Save build folder + uses: actions/upload-artifact@v4 + with: + name: dist + if-no-files-found: error + path: dist diff --git a/.github/workflows/main.yml b/.github/workflows/e2e-tests.yml similarity index 66% rename from .github/workflows/main.yml rename to .github/workflows/e2e-tests.yml index 4bf2609..1efc3d7 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/e2e-tests.yml @@ -1,58 +1,18 @@ -name: Main +name: E2E Tests on: push: branches: [ main ] - pull_request: - branches: [ main ] workflow_dispatch: jobs: - build: - runs-on: ubuntu-latest - container: - image: cypress/browsers:node-18.16.0-chrome-114.0.5735.133-1-ff-114.0.2-edge-114.0.1823.51-1 - options: --user 1001 - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Cache node_modules - uses: actions/setup-node@v4 - with: - node-version: 18 - cache: 'npm' - - - name: Cypress install - uses: cypress-io/github-action@v6 - with: - runTests: false - - - name: Write Firebase config - run: | - echo ${{ secrets.FIREBASE_CONFIG }} | base64 -d > firebase.config.json - - - run: npx cypress info - - run: node --version - - run: node -p 'os.cpus()' - - run: npm run lint - - run: npm run test:ci - - run: npm run build - - - name: Save build folder - uses: actions/upload-artifact@v4 - with: - name: dist - if-no-files-found: error - path: dist - e2e-chrome-tests: + uses: ./.github/workflows/build.yml timeout-minutes: 15 runs-on: ubuntu-latest container: image: cypress/browsers:node-18.16.0-chrome-114.0.5735.133-1-ff-114.0.2-edge-114.0.1823.51-1 options: --user 1001 - needs: build strategy: fail-fast: false # https://github.com/cypress-io/github-action/issues/48 matrix: @@ -145,23 +105,3 @@ jobs: TEST_USER_USERNAME: ${{ secrets.TEST_USER_USERNAME_2 }} TEST_USER_PASSWORD: ${{ secrets.TEST_USER_PASSWORD_2 }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - deploy_live_website: - name: Deploy Prod - needs: build - runs-on: ubuntu-latest - if: github.event_name == 'push' && github.ref == 'refs/heads/main' - steps: - - name: Checkout repository - uses: actions/checkout@main - - name: Download artifact - uses: actions/download-artifact@main - with: - name: dist - path: dist - - uses: FirebaseExtended/action-hosting-deploy@v0 - with: - repoToken: "${{ secrets.GITHUB_TOKEN }}" - firebaseServiceAccount: "${{ secrets.GOOGLE_SERVICE_ACCOUNT_KEY }}" - projectId: "${{ secrets.GOOGLE_PROJECT_ID }}" - channelId: live