From b8a85f37738d9f4f32d0882a67b7c2287f85869b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9A=D0=B8=D1=80=D0=B8=D0=BB=D0=BB=20=D0=90=D0=B7=D0=BE?= =?UTF-8?q?=D0=B2=D1=86=D0=B5=D0=B2?= Date: Sun, 8 Dec 2024 22:51:46 +0300 Subject: [PATCH 1/2] ci - run test workflow (wip) --- .github/workflows/run_tests.yaml | 62 ++++++++++++++++++++++++++++++++ .gitignore | 1 + Makefile | 8 ++--- 3 files changed, 67 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/run_tests.yaml diff --git a/.github/workflows/run_tests.yaml b/.github/workflows/run_tests.yaml new file mode 100644 index 0000000..b7887e3 --- /dev/null +++ b/.github/workflows/run_tests.yaml @@ -0,0 +1,62 @@ +name: Run Tests + +on: + push: + branches: + - master + pull_request: + workflow_dispatch: + +env: + CACHE_PATHS: | + ~/Library/Caches/pip + ~/.cargo + ~/.ccache + ~/.hunter + ~/.rustup + ~/.cache/pip + ~/.cache/vcpkg + +jobs: + build-linux: + runs-on: ubuntu-24.04 + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Cache folders + uses: actions/cache@v4 + with: + + test: + runs-on: ubuntu-24.04 + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Cache folders + uses: actions/cache@v4 + with: + path: | + build + build-debug + key: ${{ runner.os }}-build-${{ hashFiles('**/CMakeLists.txt') }} + restore-keys: | + ${{ runner.os }}-build- + + - name: Build test + working-directory: .ci + run: bash build_test.sh + + - name: Check generated files + working-directory: .ci + run: python3 check_files.py + + - name: Run cargo tests + working-directory: .ci + run: bash cargo_tests.sh + + # - name: Run tests + # working-directory: .ci + # run: bash run_all_tests.sh + \ No newline at end of file diff --git a/.gitignore b/.gitignore index a69a097..58063b0 100644 --- a/.gitignore +++ b/.gitignore @@ -38,3 +38,4 @@ /.build /.venv /.vcpkg +/.build* \ No newline at end of file diff --git a/Makefile b/Makefile index 969fae9..c9a6828 100644 --- a/Makefile +++ b/Makefile @@ -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 From f673e1ce34cd0bd4c7fa230c387c9d6729e7d271 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9A=D0=B8=D1=80=D0=B8=D0=BB=D0=BB=20=D0=90=D0=B7=D0=BE?= =?UTF-8?q?=D0=B2=D1=86=D0=B5=D0=B2?= Date: Mon, 9 Dec 2024 00:26:11 +0300 Subject: [PATCH 2/2] build and test pipeline for ci --- .ci/scripts/init_vcpkg.sh | 7 ++- .github/workflows/build_and_test.yaml | 73 +++++++++++++++++++++++++++ .github/workflows/run_tests.yaml | 62 ----------------------- .gitignore | 2 +- 4 files changed, 80 insertions(+), 64 deletions(-) create mode 100644 .github/workflows/build_and_test.yaml delete mode 100644 .github/workflows/run_tests.yaml diff --git a/.ci/scripts/init_vcpkg.sh b/.ci/scripts/init_vcpkg.sh index b409ccd..6cbafbe 100755 --- a/.ci/scripts/init_vcpkg.sh +++ b/.ci/scripts/init_vcpkg.sh @@ -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 diff --git a/.github/workflows/build_and_test.yaml b/.github/workflows/build_and_test.yaml new file mode 100644 index 0000000..3e49db2 --- /dev/null +++ b/.github/workflows/build_and_test.yaml @@ -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 }} diff --git a/.github/workflows/run_tests.yaml b/.github/workflows/run_tests.yaml deleted file mode 100644 index b7887e3..0000000 --- a/.github/workflows/run_tests.yaml +++ /dev/null @@ -1,62 +0,0 @@ -name: Run Tests - -on: - push: - branches: - - master - pull_request: - workflow_dispatch: - -env: - CACHE_PATHS: | - ~/Library/Caches/pip - ~/.cargo - ~/.ccache - ~/.hunter - ~/.rustup - ~/.cache/pip - ~/.cache/vcpkg - -jobs: - build-linux: - runs-on: ubuntu-24.04 - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Cache folders - uses: actions/cache@v4 - with: - - test: - runs-on: ubuntu-24.04 - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Cache folders - uses: actions/cache@v4 - with: - path: | - build - build-debug - key: ${{ runner.os }}-build-${{ hashFiles('**/CMakeLists.txt') }} - restore-keys: | - ${{ runner.os }}-build- - - - name: Build test - working-directory: .ci - run: bash build_test.sh - - - name: Check generated files - working-directory: .ci - run: python3 check_files.py - - - name: Run cargo tests - working-directory: .ci - run: bash cargo_tests.sh - - # - name: Run tests - # working-directory: .ci - # run: bash run_all_tests.sh - \ No newline at end of file diff --git a/.gitignore b/.gitignore index 58063b0..cd7729a 100644 --- a/.gitignore +++ b/.gitignore @@ -38,4 +38,4 @@ /.build /.venv /.vcpkg -/.build* \ No newline at end of file +/.build*