diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml deleted file mode 100644 index 7cf6a6d41..000000000 --- a/.github/actions/setup/action.yml +++ /dev/null @@ -1,21 +0,0 @@ -# In the future, I'd like to fold this into its own action under the Mithril.js -# org and include `actions/checkout` as well. It'd simplify maintenance a bit -# and I could reuse it across multiple repos. -name: Setup CI context -description: Sets up repo and Node context and installs packages - -inputs: - # See supported Node.js release schedule here: - # https://github.com/nodejs/Release - node-version: - default: 20 - description: The Node version to use - -runs: - using: composite - steps: - - uses: actions/setup-node@v4 - with: - node-version: ${{ inputs.node-version }} - - run: npm ci - shell: bash diff --git a/.github/workflows/_npm-task.yml b/.github/workflows/_npm-task.yml new file mode 100644 index 000000000..005432368 --- /dev/null +++ b/.github/workflows/_npm-task.yml @@ -0,0 +1,38 @@ +name: Run npm task + +on: + workflow_call: + inputs: + task: + type: string + required: true + node-version: + type: number + default: 20 + continue-on-error: + type: boolean + default: false + +permissions: + contents: read + +# This uses actions/checkout instead of `git clone` directly since it's way +# easier than parsing everything out. + +jobs: + run-task: + name: npm run ${{ inputs.task }} + continue-on-error: ${{ inputs.continue-on-error }} + runs-on: + - ubuntu-latest + - windows-latest + - macos-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 1 + - uses: actions/setup-node@v4 + with: + node-version: ${{ inputs.node-version }} + - run: npm ci + - run: npm run ${{ inputs.task }} diff --git a/.github/workflows/_post-comment.yml b/.github/workflows/_post-comment.yml new file mode 100644 index 000000000..82b4054a9 --- /dev/null +++ b/.github/workflows/_post-comment.yml @@ -0,0 +1,21 @@ +name: Post comment + +on: + workflow_call: + inputs: + url: + type: string + required: true + message: + type: string + required: true + +jobs: + notify: + runs-on: ubuntu-latest + steps: + - run: gh issue comment "$ISSUE_URL" --body "$MESSAGE" + env: + ISSUE_URL: ${{ inputs.url }} + MESSAGE: ${{ inputs.message }} + GITHUB_TOKEN: ${{ github.token }} diff --git a/.github/workflows/issue-create.yml b/.github/workflows/issue-create.yml index f3a56ee4e..24214b0fa 100644 --- a/.github/workflows/issue-create.yml +++ b/.github/workflows/issue-create.yml @@ -1,13 +1,12 @@ name: Ping triage on issue create - on: issues: types: [opened] - +permissions: + issues: write jobs: notify: - runs-on: ubuntu-latest - steps: - - run: gh issue comment ${{ github.event.issue.url }} --body '@MithrilJS/triage Please take a look.' - env: - GITHUB_TOKEN: ${{ github.token }} + uses: ./.github/workflows/_post-comment.yml + with: + url: ${{ github.event.issue.url }} + message: '@MithrilJS/triage Please take a look.' diff --git a/.github/workflows/merge.yml b/.github/workflows/merge.yml index 0f356c628..1980972cd 100644 --- a/.github/workflows/merge.yml +++ b/.github/workflows/merge.yml @@ -13,8 +13,13 @@ jobs: runs-on: ubuntu-latest steps: - - run: git clone --depth=1 https://github.com/MithrilJS/mithril.js.git && cd mithril.js - - uses: ./.github/actions/setup + - uses: actions/checkout@v4 + with: + ref: next + - uses: actions/setup-node@v4 + with: + node-version: 20 + - run: npm ci - run: npm run build - run: npx pr-release merge --target master --source next --commit --force --clean --changelog ./docs/recent-changes.md --compact --minimize-semver-change env: diff --git a/.github/workflows/push-master.yml b/.github/workflows/push-master.yml index 3391c8c0d..9b95880c2 100644 --- a/.github/workflows/push-master.yml +++ b/.github/workflows/push-master.yml @@ -7,11 +7,7 @@ permissions: issues: write jobs: comment: - runs-on: ubuntu-latest - steps: - - run: | - gh issue comment ${{ github.event.pull_request.url }} \ - --body '⚠⚠⚠ Hey @${{ github.actor }}, did you mean to open this against `next`? ⚠⚠⚠' - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Post alert comment + uses: ./.github/workflows/_post-comment.yml + with: + url: ${{ github.event.pull_request.url }} + message: ⚠⚠⚠ Hey @${{ github.actor }}, did you mean to open this against `next`? ⚠⚠⚠ diff --git a/.github/workflows/rollback.yml b/.github/workflows/rollback.yml index 22319dcc3..eb2d5fd1c 100644 --- a/.github/workflows/rollback.yml +++ b/.github/workflows/rollback.yml @@ -10,8 +10,11 @@ jobs: runs-on: ubuntu-latest steps: - - run: git clone --depth=1 https://github.com/MithrilJS/mithril.js.git && cd mithril.js - - uses: ./.github/actions/setup + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 20 + - run: npm ci - run: npm run build - run: npx pr-release rollback --verbose --target master --source next --verbose --ignore 'package*' --ignore docs/changelog.md --ignore docs/recent-changes.md env: diff --git a/.github/workflows/test-next-push.yml b/.github/workflows/test-next-push.yml index bbafbb2cf..3aaec97b0 100644 --- a/.github/workflows/test-next-push.yml +++ b/.github/workflows/test-next-push.yml @@ -8,15 +8,18 @@ on: concurrency: prr:pre-release jobs: - build: + test: uses: ./.github/workflows/test.yml publish-prerelease: - needs: build + needs: test runs-on: ubuntu-latest steps: - - run: git clone --depth=1 https://github.com/MithrilJS/mithril.js.git && cd mithril.js - - uses: ./.github/actions/setup + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 20 + - run: npm ci - run: npm run build - run: npx pr-release pr --verbose --target master --source next --compact --verbose --minimize-semver-change env: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d54ae7e5a..69bc69bb9 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -15,34 +15,24 @@ permissions: jobs: lint-docs: - # https://github.com/MithrilJS/mithril.js/issues/2898 - # Semantics aren't quite what I'd prefer. This is what I'd really want: - # https://github.com/actions/runner/issues/2347#issue-comment-box - continue-on-error: true - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: ./.github/actions/setup - - run: npm run lint:docs + uses: ./.github/workflows/_npm-task.yml + with: + task: lint:docs + continue-on-error: true lint-js: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: ./.github/actions/setup - - run: npm run lint:js + uses: ./.github/workflows/_npm-task.yml + with: + task: lint:js build-js: needs: lint-js - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: ./.github/actions/setup - - run: npm run build + uses: ./.github/workflows/_npm-task.yml + with: + task: build test-js: needs: build-js - runs-on: ubuntu-latest strategy: matrix: # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ @@ -51,9 +41,7 @@ jobs: - 18 - 20 - 22 - steps: - - uses: actions/checkout@v4 - - uses: ./.github/actions/setup - with: - node-version: ${{ matrix.node-version }} - - run: npm run test:js + uses: ./.github/workflows/_npm-task.yml + with: + node-version: ${{ matrix.node-version }} + task: test:js