name: Continuous integration
on:
  pull_request:
  workflow_call:
jobs:
  ci:
    runs-on: ubuntu-latest
    steps:
    - name: Checkout
      uses: actions/checkout@v2
    - name: Cache the node_modules dir
      uses: actions/cache@v2
      with:
        path: node_modules
        key: ${{ runner.os }}-node_modules-${{ hashFiles('yarn.lock') }}
    - name: Install
      run: yarn install --frozen-lockfile
    - name: Format
      run: make checkformatting
    - name: Lint & typecheck
      run: make lint
    - name: Test
      run: make test
    - name: Build packages
      run: |
        make clean # Remove assets from test step
        make build SETTINGS_FILE=settings/chrome-qa.json dist/ci-chrome-qa.zip
        make build SETTINGS_FILE=settings/chrome-prod.json dist/ci-chrome-prod.zip
        make build SETTINGS_FILE=settings/firefox-qa.json dist/ci-firefox-qa.xpi
        make build SETTINGS_FILE=settings/firefox-prod.json dist/ci-firefox-prod.xpi

name: Continuous integration
on:
  pull_request:
  workflow_call:
jobs:
  ci:
    runs-on: ubuntu-latest
    steps:
    - name: Checkout
      uses: actions/checkout@v2
    - name: Cache the node_modules dir
      uses: actions/cache@v2
      with:
        path: node_modules
        key: ${{ runner.os }}-node_modules-${{ hashFiles('yarn.lock') }}
    - name: Install
      run: yarn install --frozen-lockfile
    - name: Format
      run: make checkformatting
    - name: Lint & typecheck
      run: make lint
    - name: Test
      run: make test
    - name: Fetch git tags
      run: |
        # Fetch tags because `git describe` uses them and the output from `git describe`
        # is in turn used to produce the extension version number in `build/manifest.json`.
        #
        # GitHub does a shallow clone by default, so we have to un-shallow it for
        # `git describe` to work.
        git fetch --quiet --tags --unshallow

        # Show version information in the build logs. This command will also be
        # used by `tools/settings.js` to generate the extension version.
        git describe
    - name: Build packages
      run: |
        make clean # Remove assets from test step
        make build SETTINGS_FILE=settings/chrome-qa.json dist/ci-chrome-qa.zip
        make build SETTINGS_FILE=settings/chrome-prod.json dist/ci-chrome-prod.zip
        make build SETTINGS_FILE=settings/firefox-qa.json dist/ci-firefox-qa.xpi
        make build SETTINGS_FILE=settings/firefox-prod.json dist/ci-firefox-prod.xpi
    - name: Archive packages
      uses: actions/upload-artifact@v3
      with:
        name: packages
        path: |
          dist/*.zip
          dist/*.xpi
        retention-days: 30

Archive packages after CI run
Archive packages after CI run

Fetch git tags before building packages, so that they get correct
version numbers, and then archive them at the end of the run, so they
are available for calling workflows or just for developers to download
and share for testing.
