Skip to content

Create 'test.yml' reusable workflow #49

@oscard0m

Description

@oscard0m

📖 Description

Create a reusable test.yml workflow to be used across all the repositories of Octokit.js ecosystem.

🏁 Goal

  1. To centralize GitHub Workflows used across repositories in Octokit so we can easily maintain them in a single point
  2. To reduce the noise Renovatebot produces when a third-party GitHub Action inside our workflows has an update1.

🔭 Scope

  • As a first step, this re-usable workflow will support octokit/*{.js|.ts} only.
  • Runs npm run lint --if-present
  • Runs npm run build --if-present (context here)

🔮 Future work

  • Compose actions/checkout and actions/setup-node and evaluate the execution time (more info here)
  • Extend this workflow to support the remaining octokit/* of the JS Ecosystem (more info here)
  • To evaluate the type-only test with tsd (context here)

🚚 Migration Plan

WIP

💬 Discussion points / 🚫 Blockers

Parametrize node_versions [Solved ✅]

The idea would be to parametrize the node_versions for strategy.matrix but apparently, GitHub Action Inputs do not support string[] as an input type (see here, here and here).

Conclusion 🧑‍⚖️

We are using `fromJSON` helper (details [here](https://github.com//pull/13#discussion_r922566626))

Custom steps in test.yml [Solved ✅]

Right now, most of our test.yml used across Octokit.js repositories have the following code:

name: Test
jobs:
  test_matrix:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        node_version:
          - 18
          - 20
    steps:
      - uses: actions/checkout@v3
      - name: Use Node.js ${{ matrix.node_version }}
        uses: actions/setup-node@v3
        with:
          node-version: ${{ matrix.node_version }}
          cache: npm
      - run: npm ci
      - run: npm test
  test:
    runs-on: ubuntu-latest
    needs: test_matrix
    steps:
      - run: exit 1
        if: ${{ needs.test_matrix.result != 'success' }}
      - uses: actions/checkout@v3
      - run: npm ci
      - run: npm run lint
    if: ${{ always() }}

But there are some repositories which have extra steps or different steps:

  • What approach do we want to follow for custom steps?
    1. Extra custom-test workflows which extend a generic test.yml?
    2. Add extra logic to test.yml to give support to all the use cases?

Conclusion 🧑‍⚖️

- We want to support all the use cases by adding extra logic (more details [here](https://github.com//pull/13#issuecomment-1186010553)). - As a first step, we will focus on octokit/*{.js|.ts} repositories

Footnotes

  1. https://github.com/orgs/octokit/teams/js-community/discussions/11?from_comment=12

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions