diff --git a/.github/workflows/test-changed-firestore.yml b/.github/workflows/test-changed-firestore.yml index 1a964d8c3cd..ec890e7fab1 100644 --- a/.github/workflows/test-changed-firestore.yml +++ b/.github/workflows/test-changed-firestore.yml @@ -2,10 +2,16 @@ name: Test Firestore on: pull_request +env: + artifactRetentionDays: 14 + jobs: - test-chrome: - name: Test Firestore on Chrome and Node If Changed + build: + name: Build Firestore + runs-on: ubuntu-latest + outputs: + changed: ${{ steps.set-output.outputs.CHANGED }} steps: - name: Checkout Repo @@ -28,27 +34,112 @@ jobs: cp config/ci.config.json config/project.json yarn - name: build - run: yarn build:changed firestore - - name: Run tests if firestore or its dependencies has changed - run: yarn test:changed firestore + id: build + # TODO(wuandy): Separate yarn and egrep into steps, so build failure + # is captured by github actions. + run: yarn build:changed firestore | egrep "Skipping all" + # Continue when "Skipping all" is not found + continue-on-error: true + - name: set output + # This means "Skipping all" was not found + if: steps.build.outcome != 'success' + id: set-output + run: echo "CHANGED=true" >> "$GITHUB_OUTPUT"; + - name: Archive build + if: ${{ !cancelled() && steps.build.outcome != 'success' }} + run: | + tar -cf build.tar --exclude="\.git" . + gzip build.tar + - name: Upload build archive + if: ${{ !cancelled() && steps.build.outcome != 'success' }} + uses: actions/upload-artifact@v3 + with: + name: build.tar.gz + path: build.tar.gz + retention-days: ${{ env.artifactRetentionDays }} + + compat-test-chrome: + name: Test Firestore Compatible + runs-on: ubuntu-latest + needs: build + if: ${{ needs.build.outputs.changed == 'true'}} + steps: + - name: Set up Node (14) + uses: actions/setup-node@v3 + with: + node-version: 14.x + - name: install Chrome stable + run: | + sudo apt-get update + sudo apt-get install google-chrome-stable + - name: Download build archive + uses: actions/download-artifact@v3 + with: + name: build.tar.gz + - name: Unzip build artifact + run: tar xf build.tar.gz + - name: Bump Node memory limit + run: echo "NODE_OPTIONS=--max_old_space_size=4096" >> $GITHUB_ENV + - name: Test setup and yarn install + run: | + cp config/ci.config.json config/project.json + - name: Run compat tests + run: cd packages/firestore-compat && yarn run test:ci + + test-chrome: + name: Test Firestore + strategy: + matrix: + test-name: ["test:browser", "test:travis", "test:lite:browser", "test:browser:prod:nameddb", "test:lite:browser:nameddb"] + runs-on: ubuntu-latest + needs: build + if: ${{ needs.build.outputs.changed == 'true'}} + steps: + - name: Set up Node (14) + uses: actions/setup-node@v3 + with: + node-version: 14.x + - name: install Chrome stable + run: | + sudo apt-get update + sudo apt-get install google-chrome-stable + - name: Download build archive + uses: actions/download-artifact@v3 + with: + name: build.tar.gz + - name: Unzip build artifact + run: tar xf build.tar.gz + - name: Bump Node memory limit + run: echo "NODE_OPTIONS=--max_old_space_size=4096" >> $GITHUB_ENV + - name: Test setup and yarn install + run: | + cp config/ci.config.json config/project.json + - name: Run tests + run: cd packages/firestore && yarn run ${{ matrix.test-name }} + test-firefox: - name: Test Firestore on Firefox If Changed + name: Test Firestore on Firefox + strategy: + matrix: + test-name: ["test:browser", "test:travis", "test:lite:browser", "test:browser:prod:nameddb", "test:lite:browser:nameddb"] # Whatever version of Firefox comes with 22.04 is causing Firefox # startup to hang when launched by karma. Need to look further into # why. runs-on: ubuntu-20.04 - + needs: build + if: ${{ needs.build.outputs.changed == 'true'}} steps: - name: install Firefox stable run: | sudo apt-get update sudo apt-get install firefox - - name: Checkout Repo - uses: actions/checkout@master + - name: Download build archive + uses: actions/download-artifact@v3 with: - # This makes Actions fetch all Git history so run-changed script can diff properly. - fetch-depth: 0 + name: build.tar.gz + - name: Unzip build artifact + run: tar xf build.tar.gz - name: Set up Node (14) uses: actions/setup-node@v3 with: @@ -58,10 +149,7 @@ jobs: - name: Test setup and yarn install run: | cp config/ci.config.json config/project.json - yarn - - name: build - run: yarn build:changed firestore - - name: Run tests if firestore or its dependencies has changed - run: xvfb-run yarn test:changed firestore + - name: Run tests + run: cd packages/firestore && xvfb-run yarn run ${{ matrix.test-name }} env: BROWSERS: 'Firefox'