Skip to content

Commit fd2e781

Browse files
committed
ci: Add GitHub Workflow for running uncrustify
1 parent feac7af commit fd2e781

1 file changed

Lines changed: 63 additions & 0 deletions

File tree

.github/workflows/format.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Syntax reference https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions
2+
# Environment reference https://help.github.com/en/actions/reference/virtual-environments-for-github-hosted-runners
3+
name: format
4+
5+
on:
6+
push:
7+
branches:
8+
- 'master'
9+
- 'improve-runformat-script'
10+
- 'releases/**'
11+
- '1.*'
12+
tags:
13+
- '1.*'
14+
pull_request:
15+
16+
permissions:
17+
contents: read
18+
19+
jobs:
20+
format:
21+
22+
runs-on: ubuntu-22.04
23+
24+
defaults:
25+
run:
26+
shell: bash -euo pipefail {0}
27+
28+
env:
29+
UNCRUSTIFY_INSTALL_DIR: ${{ github.workspace }}/runformat-uncrustify
30+
31+
steps:
32+
- uses: actions/checkout@v5
33+
with:
34+
persist-credentials: false
35+
36+
- name: Determine uncrustify version
37+
id: get-uncrustify-version
38+
run: |
39+
version="$(./runformat --expected-uncrustify-version)"
40+
echo "Expected uncrustify version: $version"
41+
echo "version=$version" >> "$GITHUB_OUTPUT"
42+
43+
- name: Set UNCRUSTIFY_VERSION env variable
44+
run: |
45+
version=$(./runformat --expected-uncrustify-version)
46+
echo "version [$version]"
47+
echo "UNCRUSTIFY_VERSION=${version}" >> "$GITHUB_ENV"
48+
49+
- name: Cache uncrustify
50+
uses: actions/cache@v4
51+
id: cache-uncrustify
52+
with:
53+
path: ${{ env.UNCRUSTIFY_INSTALL_DIR }}
54+
key: ${{ runner.os }}-uncrustify-${{ steps.get-uncrustify-version.outputs.version }}
55+
56+
- name: Install uncrustify
57+
if: steps.cache-uncrustify.outputs.cache-hit != 'true'
58+
run: |
59+
./runformat --install --install-dir "${UNCRUSTIFY_INSTALL_DIR}"
60+
61+
- name: Uncrustify check
62+
run: |
63+
./runformat

0 commit comments

Comments
 (0)