Skip to content

[CI] Skip QLTY publish on fork PRs #369

[CI] Skip QLTY publish on fork PRs

[CI] Skip QLTY publish on fork PRs #369

Workflow file for this run

name: gen_pack
on:
workflow_dispatch:
pull_request:
paths-ignore:
- '**/*.md'
push:
branches: [main]
release:
types: [published]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
jobs:
lint:
runs-on: ubuntu-22.04
timeout-minutes: 5
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@ab7a9404c0f3da075243ca237b5fac12c98deaa5 # v2.19.3
with:
egress-policy: audit
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
- name: Install Ubuntu deps
run: |
sudo apt-get update
sudo apt-get install \
shellcheck
- uses: ammaraskar/gcc-problem-matcher@cb2e3f949c41b7818628f35f8484a9b0acf90cf9 # pinned commit
- name: Run ShellCheck
run: |
shellcheck -s bash -f gcc gen-pack lib/*
cov:
runs-on: ubuntu-22.04
timeout-minutes: 5
permissions:
contents: read
id-token: write
steps:
- name: Harden Runner
uses: step-security/harden-runner@ab7a9404c0f3da075243ca237b5fac12c98deaa5 # v2.19.3
with:
egress-policy: audit
- name: Checkout Repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
submodules: recursive
- name: Install Ubuntu deps
run: |
sudo apt-get update
sudo apt-get install \
dos2unix \
kcov
- name: Run kcov
run: |
./test/run_cov.sh
- name: Install XML validation deps
run: |
sudo apt-get update
sudo apt-get install --no-install-recommends \
libxml2-utils
- name: Validate coverage artifact
shell: bash
run: |
bash .github/scripts/validate-cobertura-xml.sh test/cov/all/kcov-merged/cov.xml
- name: Upload coverage HTML report
id: upload_coverage_html
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: coverage-html
path: ${{github.workspace}}/test/cov/all/kcov-merged
if-no-files-found: error
retention-days: 7
- name: Enforce minimum coverage
env:
MIN_LINE_COVERAGE: "75"
COVERAGE_HTML_ARTIFACT_URL: ${{ steps.upload_coverage_html.outputs.artifact-url }}
run: |
echo "Checking if test coverage is above $MIN_LINE_COVERAGE%"
rate=$(sed -n 's/.*line-rate="\([0-9.]*\)".*/\1/p' test/cov/all/kcov-merged/cov.xml | head -n1)
percent=$(awk "BEGIN { printf(\"%.0f\", $rate * 100) }")
echo "Line-rate: $rate ($percent%)"
if [ "$percent" -lt "$MIN_LINE_COVERAGE" ]; then
echo "Coverage below $MIN_LINE_COVERAGE%! Failing."
echo "Check Coverage HTML artifact: $COVERAGE_HTML_ARTIFACT_URL"
exit 1
fi
echo "Coverage OK."
- name: Publish coverage report to QLTY
if: >-
(success() || failure()) &&
github.repository == 'Open-CMSIS-Pack/gen-pack' &&
github.workflow != 'Release' &&
github.event.pull_request.user.login != 'dependabot[bot]' &&
(github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork == false)
uses: qltysh/qlty-action/coverage@a19242102d17e497f437d7466aa01b528537e899 # v2.2.0
with:
oidc: true
files: ${{github.workspace}}/test/cov/all/kcov-merged/cov.xml
skip-errors: false
format: cobertura
verbose: true
tests:
runs-on: ${{ matrix.os }}
timeout-minutes: 5
strategy:
fail-fast: true
matrix:
os: [ macos-14, macos-15, macos-26, ubuntu-22.04, ubuntu-24.04, ubuntu-22.04-arm, ubuntu-24.04-arm, windows-2022, windows-2025 ]
include:
- os: macos-26
target: darwin-arm64
archiveext: tar.gz
unarcmd: tar -xzf
- os: macos-15
target: darwin-arm64
archiveext: tar.gz
unarcmd: tar -xzf
- os: macos-14
target: darwin-arm64
archiveext: tar.gz
unarcmd: tar -xzf
- os: ubuntu-22.04
target: linux-amd64
archiveext: tar.gz
unarcmd: tar -xzf
- os: ubuntu-24.04
target: linux-amd64
archiveext: tar.gz
unarcmd: tar -xzf
- os: ubuntu-22.04-arm
target: linux-arm64
archiveext: tar.gz
unarcmd: tar -xzf
- os: ubuntu-24.04-arm
target: linux-arm64
archiveext: tar.gz
unarcmd: tar -xzf
- os: windows-2022
target: windows-amd64
archiveext: zip
unarcmd: 7z x
- os: windows-2025
target: windows-amd64
archiveext: zip
unarcmd: 7z x
env:
CMSIS_PACK_ROOT: ${{ github.workspace }}/.packs/
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@ab7a9404c0f3da075243ca237b5fac12c98deaa5 # v2.19.3
with:
egress-policy: audit
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
submodules: recursive
- name: Install Ubuntu deps
if: ${{ startsWith(matrix.os, 'ubuntu') }}
run: |
sudo apt-get update
sudo apt-get install \
dos2unix \
libxml2-utils
- name: Install MacOS deps
if: ${{ startsWith(matrix.os, 'macos') }}
run: |
brew install \
bash \
coreutils \
dos2unix \
gnu-tar \
grep
- name: Set up Python 3
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: '3.x'
- name: Verify Python
run: |
python3 --version
python3 -m http.server --help
- name: Install CMSIS-Toolbox
shell: bash
run: |
curl -L https://github.com/Open-CMSIS-Pack/cmsis-toolbox/releases/download/2.12.0/cmsis-toolbox-${{ matrix.target }}.${{ matrix.archiveext }} -o cmsis-toolbox-${{ matrix.target }}.${{ matrix.archiveext }}
${{ matrix.unarcmd }} cmsis-toolbox-${{ matrix.target }}.${{ matrix.archiveext }}
echo "$(pwd)/cmsis-toolbox-${{ matrix.target }}/bin" >> $GITHUB_PATH
- name: Install pack ARM.CMSIS
shell: bash
run: |
cpackget init https://www.keil.com/pack/index.pidx
cpackget add -a ARM.CMSIS
- name: Run unit tests
shell: bash
env:
LANG: en_GB.UTF-8
LC_ALL: en_GB.UTF-8
TMPDIR: ${{ github.workspace }}/../../tmp
run: |
mkdir -p ${TMPDIR}
./test/run_all.sh