Skip to content

Commit c8559a4

Browse files
authored
Merge pull request #15 from qdrvm/ci/build
Ci/build
2 parents 903bad9 + f673e1c commit c8559a4

File tree

4 files changed

+84
-5
lines changed

4 files changed

+84
-5
lines changed

.ci/scripts/init_vcpkg.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,17 @@ set -euo pipefail
33
# set -x
44

55
init_vcpkg() {
6-
if [[ ! -e $VCPKG ]]; then
6+
if [[ ! -d $VCPKG || -z "$(ls -A $VCPKG 2>/dev/null)" ]]; then
7+
echo "Directory $VCPKG does not exist or is empty. Cloning vcpkg..."
78
git clone https://github.com/microsoft/vcpkg.git $VCPKG
89
fi
10+
911
if [[ ! -e $VCPKG/vcpkg ]]; then
12+
echo "vcpkg executable not found. Bootstrapping vcpkg..."
1013
$VCPKG/bootstrap-vcpkg.sh -disableMetrics
1114
fi
15+
16+
echo "vcpkg is initialized at $VCPKG."
1217
}
1318

1419
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: Run Tests
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
workflow_dispatch:
9+
inputs:
10+
use_cache:
11+
description: 'Use cache for build'
12+
required: true
13+
default: 'true'
14+
type: 'choice'
15+
options:
16+
- 'true'
17+
- 'false'
18+
19+
env:
20+
USE_CACHE: ${{ github.event.inputs.use_cache || 'true' }}
21+
CACHE_VERSION: v01
22+
CACHE_PATHS: |
23+
~/.cargo
24+
~/.hunter
25+
~/.cache/pip
26+
~/.cache/vcpkg
27+
.vcpkg
28+
.venv
29+
.build
30+
31+
jobs:
32+
build-and-test:
33+
runs-on: ${{ matrix.os }}
34+
strategy:
35+
matrix:
36+
os: [ubuntu-24.04, macos-15]
37+
steps:
38+
- name: Checkout code
39+
uses: actions/checkout@v4
40+
41+
- name: "Restore cache dependencies"
42+
id: cache-restore
43+
if: ${{ env.USE_CACHE == 'true' }}
44+
uses: actions/cache/restore@v4
45+
with:
46+
path: ${{ env.CACHE_PATHS }}
47+
key: jam-${{ runner.os }}-${{ github.job }}-${{ env.CACHE_VERSION }}
48+
restore-keys: |
49+
jam-${{ runner.os }}-${{ github.job }}
50+
jam-${{ runner.os }}
51+
52+
- name: "Basic init"
53+
run: ./.ci/scripts/init.sh
54+
55+
- name: "Init all dependencies"
56+
run: make init_all
57+
58+
- name: "Configure"
59+
run: make configure
60+
61+
- name: "Build"
62+
run: make build
63+
64+
- name: "Test"
65+
run: make test
66+
67+
- name: "Always Save Cache"
68+
id: cache-save
69+
if: always() && ( steps.cache-restore.outputs.cache-hit != 'true' )
70+
uses: actions/cache/save@v4
71+
with:
72+
path: ${{ env.CACHE_PATH }}
73+
key: ${{ steps.cache-restore.outputs.cache-primary-key }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,4 @@
3838
/.build
3939
/.venv
4040
/.vcpkg
41+
/.build*

Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ SHELL := /bin/bash
22
PROJECT := $(shell pwd)
33
CI_DIR := $(PROJECT)/.ci
44

5-
VENV=$(PROJECT)/.venv
6-
BUILD=$(PROJECT)/.build
7-
VCPKG=$(PROJECT)/.vcpkg
8-
PATH=$(VENV)/bin:$(shell echo $$PATH)
5+
VENV ?= $(PROJECT)/.venv
6+
BUILD ?= $(PROJECT)/.build
7+
VCPKG ?= $(PROJECT)/.vcpkg
8+
PATH = $(VENV)/bin:$(shell echo $$PATH)
99

1010
ifneq (,$(wildcard $(CI_DIR)/.env))
1111
include $(CI_DIR)/.env

0 commit comments

Comments
 (0)