Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI: Download, compile and use latest cppcheck version #1310

Merged
merged 1 commit into from
Apr 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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