Skip to content

Commit 3ae3624

Browse files
committed
add simple GitHub Actions workflow which build, execute tests and create release.
1 parent 402a001 commit 3ae3624

File tree

1 file changed

+179
-0
lines changed

1 file changed

+179
-0
lines changed

.github/workflows/simple-ci.yml

Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
name: simplified-mutable-ci
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
stage:
6+
description: 'all / build-and-test / release'
7+
required: true
8+
default: all
9+
type: choice
10+
options: [all, build-and-test, release]
11+
create_release:
12+
description: 'Create GitHub Release'
13+
type: boolean
14+
default: false
15+
16+
permissions:
17+
contents: read
18+
19+
jobs:
20+
build-and-test:
21+
runs-on: ubuntu-22.04
22+
env:
23+
CC: clang
24+
CXX: clang++
25+
steps:
26+
- uses: actions/checkout@v4
27+
with: {fetch-depth: 0}
28+
29+
- name: LLVM / Clang 18 / Python env
30+
run: |
31+
wget -qO- https://apt.llvm.org/llvm.sh | sudo bash -s -- 18
32+
echo "/usr/lib/llvm-18/bin" >> $GITHUB_PATH
33+
sudo apt-get update && sudo apt-get install -y ninja-build libboost-dev libtbb-dev libfmt-dev python3-pip libssl-dev
34+
git clone https://github.com/pyenv/pyenv.git .pyenv
35+
export PYENV_ROOT="$(pwd)/.pyenv"
36+
export PATH="$PYENV_ROOT/bin:$PATH"
37+
echo "$PYENV_ROOT/bin" >> $GITHUB_PATH
38+
eval "$(pyenv init -)"
39+
sudo cp -r /usr/include/openssl /usr/lib/ssl/
40+
echo "/usr/lib/x86_64-linux-gnu" >> $GITHUB_PATH
41+
export PATH=/usr/lib/x86_64-linux-gnu:$PATH
42+
pyenv install -v 3.10.17
43+
44+
- name: Generate gitversion.tbl
45+
run: |
46+
REV=$(git rev-parse --short HEAD)
47+
BRANCH=$(git rev-parse --abbrev-ref HEAD)
48+
TAG=$(git describe --tags --always --dirty)
49+
cat > include/mutable/gitversion.tbl <<'EOF'
50+
constexpr const char GIT_REV[] = "${REV}";
51+
constexpr const char GIT_BRANCH[] = "${BRANCH}";
52+
constexpr const char SEM_VERSION[] = "${TAG}";
53+
EOF
54+
55+
- name: Configure & Build & Test
56+
# not zero exit code doesn't stop workflow
57+
shell: /usr/bin/bash {0}
58+
run: |
59+
export PYENV_ROOT="$(pwd)/.pyenv"
60+
export PATH="$PYENV_ROOT/bin:$PATH"
61+
eval "$(pyenv init -)"
62+
pyenv global 3.10.17
63+
pip install pipenv
64+
65+
cmake -S . -B build -G Ninja -LAH \
66+
-DWITH_V8=OFF \
67+
-DTHIRD_PARTY_BOOST=OFF \
68+
-DENABLE_SANITIZERS=OFF \
69+
-DMUTABLE_ENABLE_TESTS=ON \
70+
-DBUILD_TESTING=ON \
71+
-DCMAKE_BUILD_TYPE=Debug
72+
cmake --build build -j$(nproc)
73+
cmake --build build --target check-unit
74+
cmake --build build --target check-integration
75+
echo "---"
76+
find build
77+
78+
- name: Package build artifacts
79+
run: |
80+
mkdir -p artifacts
81+
82+
echo "=== Packaging build artifacts ==="
83+
cd build
84+
85+
echo "=== Available executables ==="
86+
find . -type f -executable -not -path "*/CMakeFiles/*" | sort
87+
88+
cd ..
89+
90+
find build -type f \( -executable -o -name "*.so" -o -name "*.a" \) -not -path "*/CMakeFiles/*" > file_list.txt
91+
find build -name "CTestTestfile.cmake" >> file_list.txt
92+
find build -name "cmake_install.cmake" >> file_list.txt
93+
find build -name "DartConfiguration.tcl" >> file_list.txt
94+
[ -f "build/CMakeCache.txt" ] && echo "build/CMakeCache.txt" >> file_list.txt
95+
96+
echo "Files to be archived:"
97+
cat file_list.txt
98+
99+
tar -czf artifacts/mutable-build-essential.tar.gz -T file_list.txt
100+
101+
echo "=== Build Artifacts Manifest ===" > artifacts/MANIFEST.txt
102+
echo "Generated: $(date)" >> artifacts/MANIFEST.txt
103+
echo "Commit: $(git rev-parse --short HEAD)" >> artifacts/MANIFEST.txt
104+
echo "Branch: $(git rev-parse --abbrev-ref HEAD)" >> artifacts/MANIFEST.txt
105+
echo "" >> artifacts/MANIFEST.txt
106+
echo "Contents:" >> artifacts/MANIFEST.txt
107+
tar -tzf artifacts/mutable-build-essential.tar.gz >> artifacts/MANIFEST.txt
108+
109+
- name: Upload build artifacts
110+
uses: actions/upload-artifact@v4
111+
with:
112+
name: mutable-build-${{ github.sha }}
113+
path: artifacts/
114+
retention-days: 30
115+
116+
release:
117+
if: inputs.stage == 'release' || inputs.create_release
118+
needs: build-and-test
119+
runs-on: ubuntu-22.04
120+
permissions:
121+
contents: write
122+
steps:
123+
- uses: actions/checkout@v4
124+
with: { fetch-depth: 0 }
125+
126+
- uses: actions/download-artifact@v4
127+
with:
128+
name: mutable-build-${{ github.sha }}
129+
path: artifacts/
130+
131+
- name: Prepare release package
132+
run: |
133+
mkdir -p release
134+
cp artifacts/mutable-build-essential.tar.gz release/
135+
136+
cd artifacts
137+
tar -xzf mutable-build-essential.tar.gz
138+
139+
mkdir -p ../release/mutable-release
140+
mkdir ../release/mutable-release/test
141+
mkdir ../release/mutable-release/unittest
142+
find build/unittest -type f -executable -exec cp {} ../release/mutable-release/unittest \; 2>/dev/null || true
143+
find build/test -type f -executable -exec cp {} ../release/mutable-release/unittest \; 2>/dev/null || true
144+
#find build -type f -executable -path "*/bin/*" -exec cp {} ../release/mutable-release/ \; 2>/dev/null || true
145+
#find build -type f -executable -path "*/unittest/*" -exec cp {} ../release/mutable-release/ \; 2>/dev/null || true
146+
find build -name "*.so" -o -name "*.a" | head -20 | while read lib; do
147+
cp "$lib" ../release/mutable-release/ 2>/dev/null || true
148+
done
149+
150+
cp ../README.md ../LICENSE ../release/mutable-release/ 2>/dev/null || true
151+
cp MANIFEST.txt ../release/mutable-release/
152+
153+
cd ../release
154+
tar -czf mutable-linux-x64-$(date +%Y%m%d)-$(git rev-parse --short HEAD).tar.gz mutable-release/
155+
zip -r mutable-linux-x64-$(date +%Y%m%d)-$(git rev-parse --short HEAD).zip mutable-release/
156+
157+
- name: Create Release
158+
uses: softprops/action-gh-release@v1
159+
with:
160+
tag_name: build-${{ github.run_number }}
161+
name: "Mutable Build ${{ github.run_number }}"
162+
files: |
163+
release/mutable-build-essential.tar.gz
164+
release/mutable-linux-x64-*.tar.gz
165+
release/mutable-linux-x64-*.zip
166+
body: |
167+
## Automated Build
168+
169+
**Commit:** `${{ github.sha }}`
170+
**Branch:** `${{ github.ref_name }}`
171+
**Build Date:** $(date)
172+
173+
## Downloads
174+
175+
- `mutable-build-essential.tar.gz`: Complete build artifacts
176+
- `mutable-linux-x64-*.tar.gz`: User-friendly package
177+
- `mutable-linux-x64-*.zip`: Same as above in ZIP format
178+
env:
179+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)