Skip to content

Commit 544164b

Browse files
committed
enable ccache for github actions
1 parent 97687c4 commit 544164b

File tree

6 files changed

+80
-5
lines changed

6 files changed

+80
-5
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: setup-ccache
2+
3+
inputs:
4+
max_size:
5+
description: Max ccache size
6+
default: 1G
7+
8+
cache_key_prefix:
9+
description: Cache key prefix
10+
default: "" # leave empty, auto-use repo name
11+
12+
runs:
13+
using: composite
14+
steps:
15+
- name: Install ccache (Linux)
16+
if: runner.os == 'Linux'
17+
shell: bash
18+
run: sudo apt-get update && sudo apt-get install -y ccache
19+
20+
- name: Install ccache (macOS)
21+
if: runner.os == 'macOS'
22+
shell: bash
23+
run: |
24+
export HOMEBREW_NO_AUTO_UPDATE=1
25+
brew install ccache
26+
27+
- name: Compute cache key
28+
id: cache-key
29+
shell: bash
30+
run: |
31+
if [ -n "${{ inputs.cache_key_prefix }}" ]; then
32+
PREFIX="${{ inputs.cache_key_prefix }}"
33+
else
34+
PREFIX="${GITHUB_REPOSITORY##*/}"
35+
fi
36+
echo "prefix=${PREFIX}" >> "$GITHUB_OUTPUT"
37+
echo "ccache_dir=$HOME/.ccache" >> "$GITHUB_OUTPUT"
38+
39+
- name: Restore ccache
40+
uses: actions/cache@v4
41+
with:
42+
path: ${{ steps.cache-key.outputs.ccache_dir }}
43+
key: ${{ steps.cache-key.outputs.prefix }}-${{ runner.os }}-${{ hashFiles('**/CMakeLists.txt','**/*.cmake') }}
44+
restore-keys: |
45+
${{ steps.cache-key.outputs.prefix }}-${{ runner.os }}-
46+
47+
- name: Configure ccache
48+
shell: bash
49+
run: |
50+
ccache --set-config=cache_dir=${{ steps.cache-key.outputs.ccache_dir }}
51+
ccache --set-config=max_size=${{ inputs.max_size }}

.github/workflows/linux.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ jobs:
1313
runs-on: ubuntu-latest
1414
steps:
1515
- name: Checkout
16-
uses: actions/checkout@v1
16+
uses: actions/checkout@v4
17+
- name: Setup ccache
18+
uses: ./.github/actions/setup-ccache
1719
- name: Build Linux
1820
run: ./make.sh all

.github/workflows/macos.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ jobs:
1313
runs-on: macos-latest
1414
steps:
1515
- name: Checkout
16-
uses: actions/checkout@v1
16+
uses: actions/checkout@v4
17+
- name: Setup ccache
18+
uses: ./.github/actions/setup-ccache
1719
- name: Build macOS
1820
run: ./make.sh all

make.sh

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ if [[ "${DEPS}" == "1" ]]; then
136136
fi
137137
elif [ "${OS}" == "Darwin" ]; then
138138
if command -v brew &> /dev/null; then
139-
HOMEBREW_NO_AUTO_UPDATE=1 brew install cmake openssl ncurses xapian sqlite libmagic ossp-uuid w3m || exiterr "deps failed (${OS} brew), exiting."
139+
HOMEBREW_NO_AUTO_UPDATE=1 brew install cmake openssl ncurses xapian sqlite libmagic ossp-uuid w3m 2> >(grep -vE "already installed|To reinstall|brew reinstall" >&2) || exiterr "deps failed (${OS} brew), exiting."
140140
elif command -v port &> /dev/null; then
141141
sudo port -N install openssl ncurses xapian-core sqlite3 libmagic ossp-uuid w3m || exiterr "deps failed (${OS} port), exiting."
142142
else
@@ -184,6 +184,13 @@ if [[ "${BUMP}" == "1" ]]; then
184184
fi
185185
fi
186186

187+
# ccache zero stats
188+
if [[ "${BUILD}" == "1" ]] || [[ "${DEBUG}" == "1" ]]; then
189+
if command -v ccache &> /dev/null; then
190+
ccache -z > /dev/null
191+
fi
192+
fi
193+
187194
# build
188195
if [[ "${BUILD}" == "1" ]]; then
189196
echo "-- Using cmake ${CMAKEARGS}"
@@ -199,6 +206,19 @@ if [[ "${DEBUG}" == "1" ]]; then
199206
mkdir -p dbgbuild && cd dbgbuild && cmake ${CMAKEARGS} .. && make ${MAKEARGS} && cd .. || exiterr "debug build failed, exiting."
200207
fi
201208

209+
# ccache stats
210+
if [[ "${BUILD}" == "1" ]] || [[ "${DEBUG}" == "1" ]]; then
211+
if command -v ccache &> /dev/null; then
212+
CCACHE_STATS="$(ccache -s)"
213+
HITS="$(echo "${CCACHE_STATS}" | grep "Hits:" | head -1 | awk '{print $2}')"
214+
MISSES="$(echo "${CCACHE_STATS}" | grep "Misses:" | head -1 | awk '{print $2}')"
215+
TOTAL="$(echo "${CCACHE_STATS}" | grep "Hits:" | head -1 | awk '{print $4}')"
216+
if [ -n "${HITS}" ]; then
217+
echo "-- Ccache stats: ${HITS} hits, ${MISSES} misses, ${TOTAL} total."
218+
fi
219+
fi
220+
fi
221+
202222
# tests
203223
if [[ "${TESTS}" == "1" ]]; then
204224
true # currently this project has no tests

src/nmail.1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
.\" DO NOT MODIFY THIS FILE! It was generated by help2man.
2-
.TH NMAIL "1" "February 2026" "nmail 5.11.1" "User Commands"
2+
.TH NMAIL "1" "February 2026" "nmail 5.11.2" "User Commands"
33
.SH NAME
44
nmail \- ncurses mail
55
.SH SYNOPSIS

src/version.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
#include "version.h"
99

10-
#define NMAIL_VERSION "5.11.1"
10+
#define NMAIL_VERSION "5.11.2"
1111

1212
std::string Version::GetBuildOs()
1313
{

0 commit comments

Comments
 (0)