og-northstar-launcher/.github/workflows/ci.yml
cat_or_not 47f0fa43b6
Cache nix builds on main (#921)
* cache nix artifacts to cache server instead of uploading them

* Revert "cache nix artifacts to cache server instead of uploading them"

This reverts commit d9ffaeda92.

* Revert "Revert "cache nix artifacts to cache server instead of uploading them""

This reverts commit 707b416535.

* only run on main

the motivation for this is to not completly fill my cache server instantly (which only has 15gb)

* push the store path instead of the result path
2026-06-01 19:18:06 -04:00

114 lines
3.9 KiB
YAML

name: CI
on: [push, pull_request]
env:
BUILD_PROFILE: Release
NORTHSTAR_VERSION: 0.0.0.${{github.run_number}}
jobs:
build:
runs-on: windows-2022
strategy:
matrix:
config:
- { name: "MSVC", cc: cl }
- { name: "LLVM", cc: clang-cl }
env:
CC: ${{ matrix.config.cc }}
CXX: ${{ matrix.config.cc }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: 'true'
- name: Setup msvc
uses: ilammy/msvc-dev-cmd@v1
- name: Configure cmake
run: cmake -G "Ninja" -B build -DCMAKE_BUILD_TYPE:STRING="${{ env.BUILD_PROFILE }}"
- name: Setup resource file version
shell: bash
run: |
sed -i 's/DEV/${{ env.NORTHSTAR_VERSION }}/g' primedev/primelauncher/resources.rc
sed -i 's/DEV/${{ env.NORTHSTAR_VERSION }}/g' primedev/resources.rc
FILEVERSION=$(echo ${{ env.NORTHSTAR_VERSION }} | tr '.' ',' | sed -E 's/-rc[0-9]+//' | tr -d '[:alpha:]')
sed -i "s/0,0,0,1/${FILEVERSION}/g" primedev/ns_version.h
- name: Build
run: cmake --build build/
- name: Extract Short Commit Hash
id: extract
shell: bash
run: echo commit=$(git rev-parse --short HEAD) >> $GITHUB_OUTPUT
- name: Upload Build Artifact
uses: actions/upload-artifact@v4
with:
name: NorthstarLauncher-${{ matrix.config.name }}-${{ steps.extract.outputs.commit }}
path: |
build/game/
format-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: DoozyX/clang-format-lint-action@v0.18.2
with:
source: 'primedev'
exclude: 'primedev/include primedev/thirdparty primedev/wsockproxy'
extensions: 'h,cpp'
clangFormatVersion: 16
style: file
nix-build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Nix
uses: nixbuild/nix-quick-install-action@v34
with:
# We don't enable ca-derivations here
# because we have later jobs where ca-derivations is enabled.
nix_conf: ${{ env.nix_conf }}
- name: Restore and save Nix store
uses: nix-community/cache-nix-action@v6
with:
# restore and save a cache using this key
primary-key: nix-${{ runner.os }}-${{ hashFiles('**/*.nix', '**/flake.lock') }}
# if there's no cache hit, restore a cache by this prefix
restore-prefixes-first-match: nix-${{ runner.os }}-
# collect garbage until the Nix store size (in bytes) is at most this number
# before trying to save a new cache
# 1G = 1073741824
gc-max-store-size-linux: 2G
# do purge caches
purge: false
# purge all versions of the cache
purge-prefixes: nix-${{ runner.os }}-
# created more than this number of seconds ago
purge-created: 0
# or, last accessed more than this number of seconds ago
# relative to the start of the `Post Restore and save Nix store` phase
purge-last-accessed: 604800
# except any version with the key that is the same as the `primary-key`
purge-primary-key: never
- name: Build
run: nix build
- name: Cache this Build
continue-on-error: true
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
run: |
nix run nixpkgs#attic-client -- login northstar https://attic.catornot.net ${{ secrets.ATTIC_CACHE_TOKEN }}
nix run nixpkgs#attic-client -- push northstar $(nix build --print-out-paths)
format-check-cmake-files:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: puneetmatharu/cmake-format-lint-action@v1.0.4
with:
args: "--in-place"
- run: |
git diff --exit-code