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/build #15

Merged
merged 2 commits into from
Dec 8, 2024
Merged
Show file tree
Hide file tree
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
7 changes: 6 additions & 1 deletion .ci/scripts/init_vcpkg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,17 @@ set -euo pipefail
# set -x

init_vcpkg() {
if [[ ! -e $VCPKG ]]; then
if [[ ! -d $VCPKG || -z "$(ls -A $VCPKG 2>/dev/null)" ]]; then
echo "Directory $VCPKG does not exist or is empty. Cloning vcpkg..."
git clone https://github.com/microsoft/vcpkg.git $VCPKG
fi

if [[ ! -e $VCPKG/vcpkg ]]; then
echo "vcpkg executable not found. Bootstrapping vcpkg..."
$VCPKG/bootstrap-vcpkg.sh -disableMetrics
fi

echo "vcpkg is initialized at $VCPKG."
}

if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
Expand Down
73 changes: 73 additions & 0 deletions .github/workflows/build_and_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Run Tests

on:
push:
branches:
- master
pull_request:
workflow_dispatch:
inputs:
use_cache:
description: 'Use cache for build'
required: true
default: 'true'
type: 'choice'
options:
- 'true'
- 'false'

env:
USE_CACHE: ${{ github.event.inputs.use_cache || 'true' }}
CACHE_VERSION: v01
CACHE_PATHS: |
~/.cargo
~/.hunter
~/.cache/pip
~/.cache/vcpkg
.vcpkg
.venv
.build

jobs:
build-and-test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-24.04, macos-15]
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: "Restore cache dependencies"
id: cache-restore
if: ${{ env.USE_CACHE == 'true' }}
uses: actions/cache/restore@v4
with:
path: ${{ env.CACHE_PATHS }}
key: jam-${{ runner.os }}-${{ github.job }}-${{ env.CACHE_VERSION }}
restore-keys: |
jam-${{ runner.os }}-${{ github.job }}
jam-${{ runner.os }}

- name: "Basic init"
run: ./.ci/scripts/init.sh

- name: "Init all dependencies"
run: make init_all

- name: "Configure"
run: make configure

- name: "Build"
run: make build

- name: "Test"
run: make test

- name: "Always Save Cache"
id: cache-save
if: always() && ( steps.cache-restore.outputs.cache-hit != 'true' )
uses: actions/cache/save@v4
with:
path: ${{ env.CACHE_PATH }}
key: ${{ steps.cache-restore.outputs.cache-primary-key }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,4 @@
/.build
/.venv
/.vcpkg
/.build*
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ SHELL := /bin/bash
PROJECT := $(shell pwd)
CI_DIR := $(PROJECT)/.ci

VENV=$(PROJECT)/.venv
BUILD=$(PROJECT)/.build
VCPKG=$(PROJECT)/.vcpkg
PATH=$(VENV)/bin:$(shell echo $$PATH)
VENV ?= $(PROJECT)/.venv
BUILD ?= $(PROJECT)/.build
VCPKG ?= $(PROJECT)/.vcpkg
PATH = $(VENV)/bin:$(shell echo $$PATH)

ifneq (,$(wildcard $(CI_DIR)/.env))
include $(CI_DIR)/.env
Expand Down
Loading