mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-11 06:26:26 +00:00
ci: Extract setup
job for build
workflow (#22661)
This commit is contained in:
parent
caa7235bca
commit
211b1e9e8c
1 changed files with 38 additions and 10 deletions
48
.github/workflows/build.yml
vendored
48
.github/workflows/build.yml
vendored
|
@ -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:
|
||||||
|
|
||||||
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 }}
|
||||||
|
|
Loading…
Reference in a new issue