Skip to content

Commit

Permalink
Merge pull request #1310 from eht16/ci_use_recent_cppcheck
Browse files Browse the repository at this point in the history
CI: Download, compile and use latest cppcheck version
  • Loading branch information
eht16 authored Apr 28, 2024
2 parents 8da1471 + 1562ca0 commit c2a7261
Showing 1 changed file with 35 additions and 5 deletions.
40 changes: 35 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ jobs:
env:
CC: ccache gcc
CXX: ccache g++
CPPCHECK_CACHE_PATH: ${{ github.workspace }}/.cppcheck_cache
GEANY_SOURCE_PATH: ${{ github.workspace }}/.geany_source
GEANY_CACHE_PATH: ${{ github.workspace }}/.geany_cache
GEANY_INSTALLATION_PATH: ${{ github.workspace }}/.geany_cache/_geany_install
Expand All @@ -61,17 +62,28 @@ jobs:
id: ccache_cache_timestamp
run: echo "timestamp=$(date +%Y-%m-%d-%H-%M)" >> $GITHUB_OUTPUT

- name: Prepare Cppcheck Cache Key
id: prepare_cppcheck_cache_key
run: echo "cppcheck_tag=$(curl -s https://api.github.com/repos/danmar/cppcheck/releases/latest | jq .tag_name)" >> $GITHUB_OUTPUT

- name: Prepare Geany Cache Key
id: prepare_geany_cache_key
working-directory: ${{ env.GEANY_SOURCE_PATH }}
run: echo "commit_hash=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT

- name: Configure ccache
uses: actions/cache@v4
with:
path: ${{ env.CCACHE_DIR }}
key: ${{ runner.os }}-${{ github.job }}-ccache-${{ steps.ccache_cache_timestamp.outputs.timestamp }}
restore-keys: ${{ runner.os }}-${{ github.job }}-ccache-

- name: Prepare Geany Cache Key
id: prepare_geany_cache_key
working-directory: ${{ env.GEANY_SOURCE_PATH }}
run: echo "commit_hash=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
- name: Configure Cppcheck Cache
id: cppcheck_cache
uses: actions/cache@v4
with:
path: ${{ env.CPPCHECK_CACHE_PATH }}
key: ${{ runner.os }}-${{ github.job }}-cppcheck-cache-${{ steps.prepare_cppcheck_cache_key.outputs.cppcheck_tag }}

- name: Configure Geany Cache
id: geany_cache
Expand Down Expand Up @@ -102,7 +114,6 @@ jobs:
# geany-plugins
intltool
check
cppcheck
# debugger
libvte-2.91-dev
# geanygendoc
Expand All @@ -126,9 +137,24 @@ jobs:
libxml2-dev
# spellcheck
libenchant-dev
# cppcheck
cmake
libpcre3-dev
EOF
grep -v '^[ ]*#' $RUNNER_TEMP/dependencies | xargs sudo apt-get install --assume-yes --no-install-recommends
- name: Build cppcheck
if: steps.cppcheck_cache.outputs.cache-hit != 'true'
run: |
mkdir -p ${{ env.CPPCHECK_CACHE_PATH }}
cd ${{ env.CPPCHECK_CACHE_PATH }}
curl -s https://api.github.com/repos/danmar/cppcheck/releases/latest | jq .tarball_url | xargs wget -O cppcheck.tar.gz
tar --strip-components=1 -xf cppcheck.tar.gz
mkdir build
cd build
cmake .. -DHAVE_RULES=ON -DUSE_MATCHCOMPILER=ON
cmake --build .
- name: Build Geany
if: steps.geany_cache.outputs.cache-hit != 'true'
run: |
Expand All @@ -142,6 +168,10 @@ jobs:
- name: Configure
run: |
# Add previously built cppcheck to $PATH, for this and for succeeding steps
export "PATH=$PATH:${{ env.CPPCHECK_CACHE_PATH }}/build/bin"
echo "PATH=$PATH" >> "$GITHUB_ENV"
NOCONFIGURE=1 ./autogen.sh
mkdir _build
cd _build
Expand Down

0 comments on commit c2a7261

Please sign in to comment.