From 4100507279543af2cd72e11c72c1fed0e5418bb7 Mon Sep 17 00:00:00 2001 From: Jason Karns Date: Mon, 3 Jun 2024 15:26:16 -0400 Subject: [PATCH] Separate reusable workflow from repo's own test workflow. (#38) This keeps the "combined" workflow from being too confusing (especially because we the npm job doesn't apply to this repo). This gives the added benefit of actually exercising the `workflow_call` event of the reusable workflow. --- .github/workflows/_test.yml | 18 ++++++++++++++++++ .github/workflows/test.yml | 15 ++++++++------- 2 files changed, 26 insertions(+), 7 deletions(-) create mode 100644 .github/workflows/_test.yml diff --git a/.github/workflows/_test.yml b/.github/workflows/_test.yml new file mode 100644 index 0000000..c755011 --- /dev/null +++ b/.github/workflows/_test.yml @@ -0,0 +1,18 @@ +name: Test +on: + pull_request: + push: {branches: main} + schedule: [{cron: '0 0 10 * *'}] # monthly https://crontab.guru/#0_0_10_*_* + workflow_dispatch: +permissions: {} + +jobs: + test: + uses: ./.github/workflows/test.yml + with: {npm: false} + permissions: + contents: read + packages: read + id-token: write + security-events: write + statuses: write diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ef3e4b3..563fffc 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,13 +1,14 @@ name: Test on: - pull_request: - push: {branches: main} - schedule: [{cron: '0 0 10 * *'}] # monthly https://crontab.guru/#0_0_10_*_* - workflow_dispatch: workflow_call: inputs: + npm: + description: 'Run npm-cit job.' + default: true + required: false + type: boolean superlinter: - description: 'Boolean to opt-out of super-linter.' + description: 'Run super-linter job.' default: true required: false type: boolean @@ -15,7 +16,7 @@ permissions: {contents: read} jobs: npm-cit: - if: github.event_name == 'workflow_call' # skip internal test runs + if: inputs.npm runs-on: ${{ matrix.os }}-latest strategy: {matrix: {os: [ubuntu, macOS]}} steps: @@ -23,7 +24,7 @@ jobs: - run: npm cit super-linter: - if: inputs.superlinter || github.event_name != 'workflow_call' + if: inputs.superlinter permissions: {contents: read, packages: read, statuses: write} runs-on: ubuntu-latest steps: