diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yml similarity index 97% rename from .github/workflows/build.yaml rename to .github/workflows/build.yml index 256acb6344b..7c99924ea83 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yml @@ -57,7 +57,7 @@ jobs: - name: Upload build archive uses: actions/upload-artifact@v4 with: - name: dists + name: dists-${{ github.ref }} path: | packages/**/dist repo-scripts/**/dist @@ -74,7 +74,7 @@ jobs: - name: Download build archive uses: actions/download-artifact@v4 with: - name: dists + name: dists-${{ github.ref }} - uses: actions/setup-node@v4 with: node-version-file: '.nvmrc' diff --git a/.github/workflows/test-all.yml b/.github/workflows/test-all.yml index a3b3f5ca73c..672160b7f11 100644 --- a/.github/workflows/test-all.yml +++ b/.github/workflows/test-all.yml @@ -14,7 +14,11 @@ name: Test All Packages -on: pull_request +on: + workflow_run: + workflows: ["Build"] + types: + - completed env: # make chromedriver detect installed Chrome version and download the corresponding driver @@ -30,43 +34,10 @@ env: NODE_OPTIONS: "--max_old_space_size=4096" jobs: - build: - name: Build the SDK - runs-on: ubuntu-latest - steps: - # Install Chrome so the correct version of webdriver can be installed by chromedriver when - # setting up the repo. This must be done to build and execute Auth properly. - - name: install Chrome stable - run: | - npx @puppeteer/browsers install chrome@stable - - uses: actions/checkout@v3 - - name: Set up Node (20) - uses: actions/setup-node@v4 - with: - node-version-file: '.nvmrc' - - name: Test setup and yarn install - run: | - cp config/ci.config.json config/project.json - yarn - - name: yarn build - run: yarn build - - name: Archive build - if: ${{ !cancelled() }} - run: | - tar -cf build.tar --exclude=.git . - gzip build.tar - - name: Upload build archive - if: ${{ !cancelled() }} - uses: actions/upload-artifact@v3 - with: - name: build.tar.gz - path: build.tar.gz - retention-days: ${{ env.artifactRetentionDays }} - # Auth and Firestore are built and executed in their own jobs in an attempt to reduce flakiness. test-the-rest: + if: ${{ github.event.workflow_run.conclusion == 'success'}} name: (bulk) Node.js and Browser (Chrome) Tests - needs: build runs-on: ubuntu-latest steps: # install Chrome first, so the correct version of webdriver can be installed by chromedriver when setting up the repo @@ -74,19 +45,23 @@ jobs: run: | npx @puppeteer/browsers install chrome@stable - name: Download build archive - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: - name: build.tar.gz - - name: Unzip build artifact - run: tar xf build.tar.gz - - name: Set up Node (20) - uses: actions/setup-node@v4 + name: dists-${{ github.ref }} + - uses: actions/setup-node@v4 with: node-version-file: '.nvmrc' - - name: Test setup and yarn install - run: | - cp config/ci.config.json config/project.json - yarn + cache: yarn + cache-dependency-path: yarn.lock + - name: Restore cached node_modules + uses: actions/cache@v4 + id: node_modules + with: + path: "**/node_modules" + key: node_modules-${{ runner.arch }}-${{ runner.os }}-${{ hashFiles('yarn.lock') }} + - run: yarn install --frozen-lockfile + - name: Test setup + run: cp config/ci.config.json config/project.json - name: Set start timestamp env var run: echo "FIREBASE_CI_TEST_START_TIME=$(date +%s)" >> $GITHUB_ENV - name: Run unit tests @@ -106,8 +81,8 @@ jobs: continue-on-error: true test-auth: + if: ${{ github.event.workflow_run.conclusion == 'success' }} name: (Auth) Node.js and Browser (Chrome) Tests - needs: build runs-on: ubuntu-latest steps: # install Chrome first, so the correct version of webdriver can be installed by chromedriver @@ -125,19 +100,23 @@ jobs: run: | echo $CHROME_VERSION_NOTES=$CHROME_VERSION_MISMATCH_MESSAGE - name: Download build archive - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: - name: build.tar.gz - - name: Unzip build artifact - run: tar xf build.tar.gz - - name: Set up Node (20) - uses: actions/setup-node@v4 + name: dists-${{ github.ref }} + - uses: actions/setup-node@v4 with: node-version-file: '.nvmrc' - - name: Test setup and yarn install - run: | - cp config/ci.config.json config/project.json - yarn + cache: yarn + cache-dependency-path: yarn.lock + - name: Restore cached node_modules + uses: actions/cache@v4 + id: node_modules + with: + path: "**/node_modules" + key: node_modules-${{ runner.arch }}-${{ runner.os }}-${{ hashFiles('yarn.lock') }} + - run: yarn install --frozen-lockfile + - name: Test setup + run: cp config/ci.config.json config/project.json - name: Set start timestamp env var run: echo "FIREBASE_CI_TEST_START_TIME=$(date +%s)" >> $GITHUB_ENV - name: Run unit tests @@ -156,8 +135,8 @@ jobs: continue-on-error: true test-firestore: + if: ${{ github.event.workflow_run.conclusion == 'success'}} name: (Firestore) Node.js and Browser (Chrome) Tests - needs: build runs-on: ubuntu-latest steps: # install Chrome so the correct version of webdriver can be installed by chromedriver when setting up the repo @@ -165,19 +144,23 @@ jobs: run: | npx @puppeteer/browsers install chrome@stable - name: Download build archive - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: - name: build.tar.gz - - name: Unzip build artifact - run: tar xf build.tar.gz - - name: Set up Node (20) - uses: actions/setup-node@v4 + name: dists-${{ github.ref }} + - uses: actions/setup-node@v4 with: node-version-file: '.nvmrc' - - name: Test setup and yarn install - run: | - cp config/ci.config.json config/project.json - yarn + cache: yarn + cache-dependency-path: yarn.lock + - name: Restore cached node_modules + uses: actions/cache@v4 + id: node_modules + with: + path: "**/node_modules" + key: node_modules-${{ runner.arch }}-${{ runner.os }}-${{ hashFiles('yarn.lock') }} + - run: yarn install --frozen-lockfile + - name: Test setup + run: cp config/ci.config.json config/project.json - name: Set start timestamp env var run: echo "FIREBASE_CI_TEST_START_TIME=$(date +%s)" >> $GITHUB_ENV - name: Run unit tests @@ -196,12 +179,12 @@ jobs: path-to-lcov: ./lcov-all.info continue-on-error: true test-firestore-integration: + if: ${{ github.event.workflow_run.conclusion == 'success'}} strategy: fail-fast: false matrix: persistence: ['memory', 'persistence'] name: Firestore Integration Tests (${{ matrix.persistence }}) - needs: build runs-on: ubuntu-latest steps: # install Chrome so the correct version of webdriver can be installed by chromedriver when setting up the repo @@ -209,17 +192,22 @@ jobs: run: | npx @puppeteer/browsers install chrome@stable - name: Download build archive - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: - name: build.tar.gz - - name: Unzip build artifact - run: tar xf build.tar.gz - - name: Set up Node (20) - uses: actions/setup-node@v4 + name: dists-${{ github.ref }} + - uses: actions/setup-node@v4 with: node-version-file: '.nvmrc' + cache: yarn + cache-dependency-path: yarn.lock + - name: Restore cached node_modules + uses: actions/cache@v4 + id: node_modules + with: + path: "**/node_modules" + key: node_modules-${{ runner.arch }}-${{ runner.os }}-${{ hashFiles('yarn.lock') }} + - run: yarn install --frozen-lockfile - run: cp config/ci.config.json config/project.json - - run: yarn - run: yarn build:${{ matrix.persistence }} working-directory: integration/firestore - run: xvfb-run yarn karma:singlerun