-
Notifications
You must be signed in to change notification settings - Fork 3
Fix linux & add ci #12
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
Merged
Merged
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
3289717
refactor: replace append_range with insert
kamilsa 2e8218e
refactor: simplify receive method in CoroOutcomeChannel
kamilsa 0da8502
fix: add missing break statement in switch case
kamilsa 579edcc
fix: enable position independent code in CMakeLists.txt
kamilsa 6a0d2b6
feat: add scripts and configuration for Python version check and inst…
kamilsa 06d0cea
fix: specify GCC version in environment and update alternatives in in…
kamilsa 82bb355
fix: remove Rust setup from build and init scripts
kamilsa a2fa3db
fix append
turuslan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| GCC_VERSION=14 | ||
| LINUX_PACKAGES="make \ | ||
| autoconf \ | ||
| automake \ | ||
| build-essential \ | ||
| cargo \ | ||
| curl \ | ||
| git \ | ||
| golang-go \ | ||
| libtool \ | ||
| nasm \ | ||
| ninja-build \ | ||
| pkg-config \ | ||
| python3.12 \ | ||
| python3.12-dev \ | ||
| python3.12-venv \ | ||
| python3-pip \ | ||
| gcc-$GCC_VERSION \ | ||
| g++-$GCC_VERSION \ | ||
| unzip \ | ||
| zip \ | ||
| nano" | ||
|
|
||
| MACOS_PACKAGES="make \ | ||
| autoconf \ | ||
| automake \ | ||
| rust \ | ||
| curl \ | ||
| git \ | ||
| go \ | ||
| libtool \ | ||
| nasm \ | ||
| ninja \ | ||
| pkg-config \ | ||
| [email protected] \ | ||
| unzip \ | ||
| zip" | ||
|
|
||
| CMAKE_VERSION=3.31.1 | ||
| DEBIAN_FRONTEND=noninteractive | ||
| #VCPKG_FORCE_SYSTEM_BINARIES=1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| #!/usr/bin/env bash | ||
| set -euo pipefail | ||
| # set -x | ||
|
|
||
| detect_os() { | ||
| if [[ "$OSTYPE" == "linux-gnu"* ]]; then | ||
| if command -v apt >/dev/null 2>&1; then | ||
| echo "linux_deb" | ||
| else | ||
| echo "linux_other" | ||
| fi | ||
| elif [[ "$OSTYPE" == "darwin"* ]]; then | ||
| echo "macos" | ||
| else | ||
| echo "unknown" | ||
| fi | ||
| } | ||
|
|
||
| if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then | ||
| echo "This script is intended to be sourced or used as a library." | ||
| echo "Exported functions: detect_os" | ||
| exit 1 | ||
| fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| #!/usr/bin/env bash | ||
| set -euo pipefail | ||
| # set -x | ||
| trap 'echo "=== Error on line $LINENO"; exit 1' ERR | ||
|
|
||
| SCRIPT_DIR="$(dirname "${BASH_SOURCE[0]}")" | ||
| OS_SELECT=$(source ${SCRIPT_DIR}/detect_os.sh && detect_os) | ||
|
|
||
| set -o allexport && . ${SCRIPT_DIR}/../.env && set +o allexport | ||
|
|
||
| main() { | ||
| case "$OS_SELECT" in | ||
| linux_deb) | ||
| echo "=== Detected Linux system with apt" | ||
| apt update && apt install -y $LINUX_PACKAGES | ||
| update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-$GCC_VERSION 90 | ||
| update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-$GCC_VERSION 90 | ||
| ;; | ||
| linux_other) | ||
| echo "=== Detected Linux system without apt" | ||
| echo "=== Support for other package managers is not added" | ||
| ;; | ||
| macos) | ||
| echo "=== Detected macOS system" | ||
| if command -v brew >/dev/null 2>&1; then | ||
| echo "=== Homebrew found. Installing packages..." | ||
| brew update && brew install $MACOS_PACKAGES | ||
| else | ||
| echo "=== Homebrew is not installed. Install it before proceeding: https://brew.sh" | ||
| fi | ||
| ;; | ||
| *) | ||
| echo "=== Unknown system" | ||
| ;; | ||
| esac | ||
| } | ||
|
|
||
| main | ||
|
|
||
| exit 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| #!/usr/bin/env bash | ||
| set -euo pipefail | ||
| # set -x | ||
|
|
||
| init_py() { | ||
| echo "$VENV" | ||
| python3 -m venv "$VENV" | ||
| source $VENV/bin/activate | ||
| pip3 install cmake==${CMAKE_VERSION} | ||
| pip3 install --no-cache-dir asn1tools | ||
| } | ||
|
|
||
| if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then | ||
| echo "This script is intended to be sourced or used as a library." | ||
| echo "Exported functions: init_py" | ||
| exit 1 | ||
| fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| #!/usr/bin/env bash | ||
| set -euo pipefail | ||
| # set -x | ||
|
|
||
| init_vcpkg() { | ||
| 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 | ||
| echo "This script is intended to be sourced or used as a library." | ||
| echo "Exported functions: init_vcpkg" | ||
| exit 1 | ||
| fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| 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: v02 | ||
| CACHE_PATH: | | ||
| ~/.hunter | ||
| ~/.cache/pip | ||
| ~/.cache/vcpkg | ||
| .vcpkg | ||
| .venv | ||
| .build | ||
|
|
||
|
|
||
| jobs: | ||
| build-and-test: | ||
| runs-on: ${{ matrix.os }} | ||
| strategy: | ||
| matrix: | ||
| os: [ubuntu-24.04, macos-15] | ||
| fail-fast: false | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| submodules: true | ||
| fetch-depth: 0 | ||
|
|
||
| - name: "Restore cache dependencies" | ||
| id: cache-restore | ||
| if: ${{ env.USE_CACHE == 'true' }} | ||
| uses: actions/cache/restore@v4 | ||
| with: | ||
| path: ${{ env.CACHE_PATH }} | ||
| key: lean-${{ runner.os }}-${{ github.job }}-${{ env.CACHE_VERSION }}-${{ github.run_id }} | ||
| restore-keys: | | ||
| lean-${{ runner.os }}-${{ github.job }}-${{ env.CACHE_VERSION }} | ||
| lean-${{ runner.os }}-${{ github.job }} | ||
| lean-${{ runner.os }} | ||
|
|
||
| - name: "Basic init" | ||
| run: | | ||
| if [[ $RUNNER_OS == "Linux" ]]; then | ||
| sudo ./.ci/scripts/init.sh | ||
| else | ||
| ./.ci/scripts/init.sh | ||
| fi | ||
|
|
||
| - name: "Init all dependencies" | ||
| run: | | ||
| make init_py | ||
| make init_vcpkg | ||
|
|
||
| - 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 }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| 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) | ||
|
|
||
| ifneq (,$(wildcard $(CI_DIR)/.env)) | ||
| include $(CI_DIR)/.env | ||
| export | ||
| endif | ||
|
|
||
| OS_TYPE := $(shell bash -c 'source $(CI_DIR)/scripts/detect_os.sh && detect_os') | ||
|
|
||
|
|
||
| all: init_all configure build test | ||
|
|
||
| init_all: init init_py init_vcpkg | ||
|
|
||
| os: | ||
| @echo "=== Detected OS: $(OS_TYPE)" | ||
|
|
||
| init: | ||
| @echo "=== Initializing..." | ||
| $(CI_DIR)/scripts/init.sh | ||
|
|
||
| init_py: | ||
| @echo "=== Initializing Python..." | ||
| source $(CI_DIR)/scripts/init_py.sh && init_py | ||
|
|
||
| init_vcpkg: | ||
| @echo "=== Initializing Vcpkg..." | ||
| source $(CI_DIR)/scripts/init_vcpkg.sh && init_vcpkg | ||
|
|
||
| configure: | ||
| @echo "=== Configuring..." | ||
| VCPKG_ROOT=$(VCPKG) cmake --preset=default -DPython3_EXECUTABLE="$(VENV)/bin/python3" -B $(BUILD) $(PROJECT) | ||
|
|
||
| build: | ||
| @echo "=== Building..." | ||
| cmake --build $(BUILD) | ||
|
|
||
| test: | ||
| @echo "=== Testing..." | ||
| ctest --test-dir $(BUILD) | ||
|
|
||
| clean_all: | ||
| @echo "=== Cleaning..." | ||
| rm -rf $(VENV) $(BUILD) $(VCPKG) | ||
|
|
||
| .PHONY: all init_all os init init_py init_vcpkg configure build test clean_all |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Adding a break statement in the default case of a switch where all other cases return is unnecessary. The break statement serves no purpose here since the function will return immediately after the switch block anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that was needed to fix gcc-14 build