Skip to content
Snippets Groups Projects
Unverified Commit 211b1e9e authored by Sergei Zharinov's avatar Sergei Zharinov Committed by GitHub
Browse files

ci: Extract `setup` job for `build` workflow (#22661)

parent caa7235b
No related branches found
No related tags found
No related merge requests found
...@@ -29,7 +29,44 @@ env: ...@@ -29,7 +29,44 @@ env:
DRY_RUN: true DRY_RUN: true
jobs: jobs:
setup:
runs-on: ubuntu-latest
outputs:
os-matrix: ${{ steps.os-matrix.outputs.os-matrix }}
env:
# Field required for GitHub CLI
GH_REPO: ${{ github.event.repository.full_name }}
GH_TOKEN: ${{ github.token }}
# Pull Request data may present or it may not
PR: ${{ github.event.pull_request.number }}
PR_LABELS: '[]'
steps:
- name: Fetch PR data
if: ${{ env.PR }}
env:
PR_URL: https://api.github.com/repos/{owner}/{repo}/pulls/${{ env.PR }}
JQ_FILTER: >-
"PR_LABELS=" + ([.labels[].name] | tostring)
run: gh api ${{ env.PR_URL }} | jq -rc '${{ env.JQ_FILTER }}' >> "$GITHUB_ENV"
- name: Detect OS matrix
id: os-matrix
env:
CI_FULLTEST: >-
${{ contains(fromJSON(env.PR_LABELS), 'ci:fulltest') && 'true' || '' }}
OS_ALL: '["ubuntu-latest", "macos-latest", "windows-latest"]'
OS_LINUX_ONLY: '["ubuntu-latest"]'
run: >-
echo 'os-matrix=${{
(!env.PR || env.CI_FULLTEST) && env.OS_ALL || env.OS_LINUX_ONLY
}}' >> "$GITHUB_OUTPUT"
test: test:
needs: setup
name: ${{ matrix.node-version == 18 && format('test ({0})', matrix.os) || format('test ({0}, node-{1})', matrix.os, matrix.node-version) }} name: ${{ matrix.node-version == 18 && format('test ({0})', matrix.os) || format('test ({0}, node-{1})', matrix.os, matrix.node-version) }}
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
...@@ -38,17 +75,8 @@ jobs: ...@@ -38,17 +75,8 @@ jobs:
strategy: strategy:
matrix: matrix:
os: [ubuntu-latest] os: ${{ fromJSON(needs.setup.outputs.os-matrix) }}
node-version: [18] node-version: [18]
# skip macOS and Windows test on pull requests without 'ci:fulltest' label
include: >-
${{ fromJSON((github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'ci:fulltest')) && '[{
"os": "macos-latest",
"node-version": 18
}, {
"os": "windows-latest",
"node-version": 18
}]' || '[]') }}
env: env:
coverage: ${{ matrix.os == 'ubuntu-latest' && matrix.node-version == 18 }} coverage: ${{ matrix.os == 'ubuntu-latest' && matrix.node-version == 18 }}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment