diff --git a/.github/workflows/build-lint-test.yml b/.github/workflows/build-lint-test.yml new file mode 100644 index 00000000..164d6c94 --- /dev/null +++ b/.github/workflows/build-lint-test.yml @@ -0,0 +1,99 @@ +name: Build, Lint, and Test + +on: + workflow_call: + +jobs: + prepare: + name: Prepare + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Use Node.js + uses: actions/setup-node@v3 + with: + node-version-file: '.nvmrc' + cache: 'yarn' + - name: Install Yarn dependencies + run: yarn --immutable + + build: + name: Build + runs-on: ubuntu-latest + needs: + - prepare + strategy: + matrix: + node-version: [14.x, 16.x, 18.x, 19.x] + steps: + - uses: actions/checkout@v3 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + cache: 'yarn' + - run: yarn --immutable --immutable-cache + - run: yarn build + - name: Require clean working directory + shell: bash + run: | + if ! git diff --exit-code; then + echo "Working tree dirty at end of job" + exit 1 + fi + + lint: + name: Lint + runs-on: ubuntu-latest + needs: + - prepare + strategy: + matrix: + node-version: [14.x, 16.x, 18.x, 19.x] + steps: + - uses: actions/checkout@v3 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + cache: 'yarn' + - run: yarn --immutable --immutable-cache + - run: yarn lint + - name: Validate RC changelog + if: ${{ startsWith(github.head_ref, 'release/') }} + run: yarn auto-changelog validate --rc + - name: Validate changelog + if: ${{ !startsWith(github.head_ref, 'release/') }} + run: yarn auto-changelog validate + - name: Require clean working directory + shell: bash + run: | + if ! git diff --exit-code; then + echo "Working tree dirty at end of job" + exit 1 + fi + + test: + name: Test + runs-on: ubuntu-latest + needs: + - prepare + strategy: + matrix: + node-version: [14.x, 16.x, 18.x, 19.x] + steps: + - uses: actions/checkout@v3 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + cache: 'yarn' + - run: yarn --immutable --immutable-cache + - run: yarn test + - name: Require clean working directory + shell: bash + run: | + if ! git diff --exit-code; then + echo "Working tree dirty at end of job" + exit 1 + fi diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml deleted file mode 100644 index 58ca8b5c..00000000 --- a/.github/workflows/build-test.yml +++ /dev/null @@ -1,119 +0,0 @@ -name: Build, Lint, and Test - -on: - push: - branches: [main] - pull_request: - -jobs: - prepare: - name: Prepare - runs-on: ubuntu-latest - outputs: - YARN_CACHE_DIR: ${{ steps.yarn-cache-dir.outputs.YARN_CACHE_DIR }} - YARN_VERSION: ${{ steps.yarn-version.outputs.YARN_VERSION }} - strategy: - matrix: - node-version: [14.x, 16.x, 18.12.1, 19.x] - steps: - - uses: actions/checkout@v3 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v3 - with: - node-version: ${{ matrix.node-version }} - - name: Get Yarn cache directory - run: echo "YARN_CACHE_DIR=$(yarn config get cacheFolder)" >> "$GITHUB_OUTPUT" - id: yarn-cache-dir - - name: Get Yarn version - run: echo "YARN_VERSION=$(yarn --version)" >> "$GITHUB_OUTPUT" - id: yarn-version - - name: Cache Yarn dependencies - uses: actions/cache@v3 - with: - path: ${{ steps.yarn-cache-dir.outputs.YARN_CACHE_DIR }} - key: yarn-cache-${{ runner.os }}-${{ steps.yarn-version.outputs.YARN_VERSION }}-${{ hashFiles('yarn.lock') }}-${{ matrix.node-version }} - - name: Install Yarn dependencies - run: yarn --immutable - lint: - name: Lint - runs-on: ubuntu-latest - needs: - - prepare - strategy: - matrix: - node-version: [14.x, 16.x, 18.12.1, 19.x] - steps: - - uses: actions/checkout@v3 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v3 - with: - node-version: ${{ matrix.node-version }} - - name: Restore Yarn dependencies - uses: actions/cache@v3 - with: - path: ${{ needs.prepare.outputs.YARN_CACHE_DIR }} - key: yarn-cache-${{ runner.os }}-${{ needs.prepare.outputs.YARN_VERSION }}-${{ hashFiles('yarn.lock') }}-${{ matrix.node-version }} - - run: yarn --immutable - - run: yarn lint - - name: Validate RC changelog - if: ${{ startsWith(github.head_ref, 'release/') }} - run: yarn auto-changelog validate --rc - - name: Validate changelog - if: ${{ !startsWith(github.head_ref, 'release/') }} - run: yarn auto-changelog validate - - name: Require clean working directory - shell: bash - run: | - if ! git diff --exit-code; then - echo "Working tree dirty at end of job" - exit 1 - fi - test: - name: Test - runs-on: ubuntu-latest - needs: - - prepare - strategy: - matrix: - node-version: [14.x, 16.x, 18.12.1, 19.x] - steps: - - uses: actions/checkout@v3 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v3 - with: - node-version: ${{ matrix.node-version }} - - name: Restore Yarn dependencies - uses: actions/cache@v3 - with: - path: ${{ needs.prepare.outputs.YARN_CACHE_DIR }} - key: yarn-cache-${{ runner.os }}-${{ needs.prepare.outputs.YARN_VERSION }}-${{ hashFiles('yarn.lock') }}-${{ matrix.node-version }} - - run: yarn --immutable - - run: yarn test - - name: Require clean working directory - shell: bash - run: | - if ! git diff --exit-code; then - echo "Working tree dirty at end of job" - exit 1 - fi - check-workflows: - name: Check workflows - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Download actionlint - id: download-actionlint - run: bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/d5f726fb9c9aaff30c8c3787a9b9640f7612838a/scripts/download-actionlint.bash) 1.6.21 - shell: bash - - name: Check workflow files - run: ${{ steps.download-actionlint.outputs.executable }} -color - shell: bash - all-jobs-pass: - name: All jobs pass - runs-on: ubuntu-latest - needs: - - lint - - test - - check-workflows - steps: - - run: echo "Great success!" diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 00000000..55fb6fd9 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,49 @@ +name: Main + +on: + push: + branches: [main] + pull_request: + +jobs: + check-workflows: + name: Check workflows + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Download actionlint + id: download-actionlint + run: bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/7fdc9630cc360ea1a469eed64ac6d78caeda1234/scripts/download-actionlint.bash) 1.6.23 + shell: bash + - name: Check workflow files + run: ${{ steps.download-actionlint.outputs.executable }} -color + shell: bash + + build-lint-test: + name: Build, lint, and test + uses: ./.github/workflows/build-lint-test.yml + + all-jobs-completed: + name: All jobs completed + runs-on: ubuntu-latest + needs: + - build-lint-test + outputs: + PASSED: ${{ steps.set-output.outputs.PASSED }} + steps: + - name: Set PASSED output + id: set-output + run: echo "PASSED=true" >> "$GITHUB_OUTPUT" + + all-jobs-pass: + name: All jobs pass + if: ${{ always() }} + runs-on: ubuntu-latest + needs: all-jobs-completed + steps: + - name: Check that all jobs have passed + run: | + passed="${{ needs.all-jobs-completed.outputs.PASSED }}" + if [[ $passed != "true" ]]; then + exit 1 + fi