From 7ae6f612ecdfb8f5e8960b4371893adca80e7809 Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Thu, 14 Sep 2023 11:08:42 +0200 Subject: [PATCH] Revert "for now, remove all other builds and run on PRs" This reverts commit 2264997715e1c34dbad354da48d18062f860509a. --- .github/workflows/close-stale.yml | 48 ++++++++ .github/workflows/issues.yml | 28 +++++ .github/workflows/lock.yml | 32 +++++ .github/workflows/nightly.yml | 3 - .github/workflows/nodejs.yml | 195 ++++++++++++++++++++++++++++++ .github/workflows/test.yml | 64 ++++++++++ 6 files changed, 367 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/close-stale.yml create mode 100644 .github/workflows/issues.yml create mode 100644 .github/workflows/lock.yml create mode 100644 .github/workflows/nodejs.yml create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/close-stale.yml b/.github/workflows/close-stale.yml new file mode 100644 index 000000000000..2894e8f0b5cb --- /dev/null +++ b/.github/workflows/close-stale.yml @@ -0,0 +1,48 @@ +name: 'Close stale issues and PRs' +on: + schedule: + - cron: '0 * * * *' + +permissions: + issues: write # to close stale issues (actions/stale) + pull-requests: write # to close stale PRs (actions/stale) + +jobs: + stale: + name: 'Close month old issues and PRs' + runs-on: ubuntu-latest + steps: + - uses: actions/stale@v8 + with: + start-date: '2022-01-01T00:00:00Z' + stale-issue-message: 'This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.' + stale-pr-message: 'This PR is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 30 days.' + close-issue-message: 'This issue was closed because it has been stalled for 30 days with no activity. Please open a new issue if the issue is still relevant, linking to this one.' + close-pr-message: 'This PR was closed because it has been stalled for 30 days with no activity. Please open a new PR if the issue is still relevant, linking to this one.' + days-before-issue-stale: 30 + days-before-pr-stale: 90 + days-before-issue-close: 30 + days-before-pr-close: 30 + exempt-all-milestones: true + exempt-issue-labels: Pinned + exempt-pr-labels: Pinned + exempt-draft-pr: true + operations-per-run: 1750 + stale-legacy: + name: 'Close year old issues and PRs' + runs-on: ubuntu-latest + steps: + - uses: actions/stale@v8 + with: + stale-issue-message: 'This issue is stale because it has been open for 1 year with no activity. Remove stale label or comment or this will be closed in 30 days.' + stale-pr-message: 'This PR is stale because it has been open 1 year with no activity. Remove stale label or comment or this will be closed in 30 days.' + close-issue-message: 'This issue was closed because it has been stalled for 30 days with no activity. Please open a new issue if the issue is still relevant, linking to this one.' + close-pr-message: 'This PR was closed because it has been stalled for 30 days with no activity. Please open a new PR if the issue is still relevant, linking to this one.' + days-before-issue-stale: 365 + days-before-pr-stale: 365 + days-before-issue-close: 30 + days-before-pr-close: 30 + exempt-all-milestones: true + exempt-issue-labels: Pinned + exempt-pr-labels: Pinned + operations-per-run: 1750 diff --git a/.github/workflows/issues.yml b/.github/workflows/issues.yml new file mode 100644 index 000000000000..88dfd8f78d76 --- /dev/null +++ b/.github/workflows/issues.yml @@ -0,0 +1,28 @@ +name: 'Close issues' + +on: + issues: + types: [labeled] + +permissions: + issues: write # to close issues (peter-evans/close-issue) + +jobs: + questions: + name: Questions + runs-on: ubuntu-latest + steps: + - if: "${{ github.event.label.name == ':speech_balloon: Question' }}" + run: gh issue close $ISSUE --comment "Please note this issue tracker is not a help forum. We recommend using [StackOverflow](https://stackoverflow.com/questions/tagged/jestjs) or our [discord channel](https://discord.gg/j6FKKQQrW9) for questions." + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + ISSUE: ${{ github.event.issue.html_url }} + bug-without-repro: + name: Bug reports without reproductions + runs-on: ubuntu-latest + steps: + - if: "${{ github.event.label.name == 'Needs Reproduction' }}" + run: gh issue close $ISSUE --comment "As noted in the [Bug Report template](https://github.com/jestjs/jest/blob/main/.github/ISSUE_TEMPLATE/bug.yml), all bug reports requires a minimal reproduction. Please open up a new issue providing one. Read more at https://stackoverflow.com/help/minimal-reproducible-example." + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + ISSUE: ${{ github.event.issue.html_url }} diff --git a/.github/workflows/lock.yml b/.github/workflows/lock.yml new file mode 100644 index 000000000000..d5a8105dae81 --- /dev/null +++ b/.github/workflows/lock.yml @@ -0,0 +1,32 @@ +name: 'Lock Threads' + +on: + schedule: + - cron: '0 0 * * *' + +permissions: {} +jobs: + lock: + permissions: + issues: write # to lock issues (dessant/lock-threads) + pull-requests: write # to lock PRs (dessant/lock-threads) + + runs-on: ubuntu-latest + steps: + - uses: dessant/lock-threads@v4 + with: + github-token: ${{ github.token }} + issue-inactive-days: '30' + exclude-any-issue-labels: 'Discussion' + issue-comment: > + This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. + + Please note this issue tracker is not a help forum. We recommend using [StackOverflow](https://stackoverflow.com/questions/tagged/jestjs) or our [discord channel](https://discord.gg/j6FKKQQrW9) for questions. + + + pr-inactive-days: '30' + pr-comment: > + This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. + + Please note this issue tracker is not a help forum. We recommend using [StackOverflow](https://stackoverflow.com/questions/tagged/jestjs) or our [discord channel](https://discord.gg/j6FKKQQrW9) for questions. + diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 48c05e1d2ba4..c7753bf5eac4 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -4,9 +4,6 @@ on: workflow_dispatch: schedule: - cron: '0 12 * * *' - pull_request: - branches: - - '**' concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml new file mode 100644 index 000000000000..e22167c6bde7 --- /dev/null +++ b/.github/workflows/nodejs.yml @@ -0,0 +1,195 @@ +name: Node CI + +on: + push: + branches: + - main + pull_request: + branches: + - '**' + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +permissions: + contents: read # to fetch code (actions/checkout) + +jobs: + prepare-yarn-cache-ubuntu: + uses: ./.github/workflows/prepare-cache.yml + with: + os: ubuntu-latest + prepare-yarn-cache-macos: + uses: ./.github/workflows/prepare-cache.yml + with: + os: macos-latest + prepare-yarn-cache-windows: + uses: ./.github/workflows/prepare-cache.yml + with: + os: windows-latest + + ts-compatibility: + name: TypeScript Compatibility + runs-on: ubuntu-latest + needs: prepare-yarn-cache-ubuntu + + steps: + - uses: actions/checkout@v4 + with: + persist-credentials: false + - uses: actions/setup-node@v3 + with: + node-version: lts/* + cache: yarn + - name: install + run: yarn --immutable + - name: build + run: yarn build + - name: ts integration + run: yarn test-ts --selectProjects ts-integration + - name: type tests + run: yarn test-ts --selectProjects type-tests + - name: verify TypeScript@4.3 compatibility + run: yarn verify-old-ts + - name: run ESLint with type info + run: yarn lint-ts-files + + typecheck: + name: Typecheck Examples and Tests + runs-on: ubuntu-latest + needs: prepare-yarn-cache-ubuntu + + steps: + - uses: actions/checkout@v4 + with: + persist-credentials: false + - uses: actions/setup-node@v3 + with: + node-version: lts/* + cache: yarn + - name: install + run: yarn --immutable + - name: build + run: yarn build:ts + - name: typecheck examples + run: yarn typecheck:examples + - name: typecheck tests + run: yarn typecheck:tests + + lint: + name: Lint + runs-on: ubuntu-latest + needs: prepare-yarn-cache-ubuntu + + steps: + - uses: actions/checkout@v4 + with: + persist-credentials: false + - uses: actions/setup-node@v3 + with: + node-version: lts/* + cache: yarn + - name: install + run: yarn --immutable + - name: build + run: yarn build:js + - name: verify Yarn PnP compatibility + run: yarn verify-pnp + - name: run eslint + run: yarn lint + - name: run prettier + run: yarn lint:prettier:ci + - name: check changelog + run: yarn check-changelog + - name: check copyright headers + run: yarn check-copyright-headers + + yarn-validate: + name: Validate Yarn dependencies and constraints + runs-on: ubuntu-latest + needs: prepare-yarn-cache-ubuntu + steps: + - uses: actions/checkout@v4 + with: + persist-credentials: false + - uses: actions/setup-node@v3 + with: + node-version: lts/* + cache: yarn + - name: 'Check for unmet constraints (fix w/ "yarn constraints --fix")' + run: yarn constraints + - name: 'Check for duplicate dependencies (fix w/ "yarn dedupe")' + run: yarn dedupe --check + + test-ubuntu: + uses: ./.github/workflows/test.yml + needs: prepare-yarn-cache-ubuntu + with: + os: ubuntu-latest + test-macos: + uses: ./.github/workflows/test.yml + needs: prepare-yarn-cache-macos + with: + os: macos-latest + test-windows: + uses: ./.github/workflows/test.yml + needs: prepare-yarn-cache-windows + with: + os: windows-latest + + test-leak: + name: Node LTS on Ubuntu with leak detection + runs-on: ubuntu-latest + needs: prepare-yarn-cache-ubuntu + + steps: + - uses: actions/checkout@v4 + with: + persist-credentials: false + - name: Use Node.js LTS + uses: actions/setup-node@v3 + with: + node-version: lts/* + cache: yarn + - name: install + run: yarn --immutable + - name: build + run: yarn build:js + - name: run tests with leak detection + run: yarn test-leak + + test-coverage: + name: Node LTS on Ubuntu with coverage (${{ matrix.shard }}) + strategy: + fail-fast: false + matrix: + shard: ['1/4', '2/4', '3/4', '4/4'] + runs-on: ubuntu-latest + needs: prepare-yarn-cache-ubuntu + + steps: + - uses: actions/checkout@v4 + with: + persist-credentials: false + - name: Use Node.js LTS + uses: actions/setup-node@v3 + with: + node-version: lts/* + cache: yarn + - name: install + run: yarn --immutable + - name: build + run: yarn build:js + - name: Get number of CPU cores + id: cpu-cores + uses: SimenB/github-actions-cpu-cores@v2 + - name: run tests with coverage + run: yarn jest-coverage --color --config jest.config.ci.mjs --max-workers ${{ steps.cpu-cores.outputs.count }} --shard=${{ matrix.shard }} + - name: map coverage + run: node ./scripts/mapCoverage.mjs + if: always() + - uses: codecov/codecov-action@v3 + if: always() + with: + directory: ./coverage diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 000000000000..dc7c7a2458ae --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,64 @@ +name: Test + +on: + workflow_call: + inputs: + os: + required: true + type: string + +jobs: + test: + strategy: + fail-fast: false + matrix: + node-version: [14.x, 16.x, 18.x, 19.x, 20.x] + shard: ['1/4', '2/4', '3/4', '4/4'] + name: Node v${{ matrix.node-version }} on ${{ inputs.os }} (${{ matrix.shard }}) + runs-on: ${{ inputs.os }} + + steps: + - uses: actions/checkout@v4 + with: + persist-credentials: false + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + cache: yarn + - name: install + run: yarn --immutable + - name: build + run: yarn build:js + - name: Get number of CPU cores + id: cpu-cores + uses: SimenB/github-actions-cpu-cores@v2 + - name: run tests + run: yarn test-ci-partial:parallel --max-workers ${{ steps.cpu-cores.outputs.count }} --shard=${{ matrix.shard }} + + test-jasmine: + strategy: + fail-fast: false + matrix: + shard: ['1/4', '2/4', '3/4', '4/4'] + name: Node LTS on ${{ inputs.os }} using jest-jasmine2 (${{ matrix.shard }}) + runs-on: ${{ inputs.os }} + + steps: + - uses: actions/checkout@v4 + with: + persist-credentials: false + - name: Use Node.js LTS + uses: actions/setup-node@v3 + with: + node-version: lts/* + cache: yarn + - name: install + run: yarn --immutable + - name: build + run: yarn build:js + - name: Get number of CPU cores + id: cpu-cores + uses: SimenB/github-actions-cpu-cores@v2 + - name: run tests using jest-jasmine + run: yarn jest-jasmine-ci --max-workers ${{ steps.cpu-cores.outputs.count }} --shard=${{ matrix.shard }}