mirror of
https://github.com/4jcraft/4jcraft.git
synced 2026-04-23 14:33:36 +00:00
Ci/make build linux use flake.nix (#394)
* make `build-linux` use `flake.nix` * fix: `on pull_request` not `on pull-request` * fix: shouldn't declare paths for a list * fix: typo in release job build path * fix: move ccache dir creation to `restore-cache.yml` * fix: `runner.temp` should be `RUNNER_TEMP` * fix: env vars should be constructed in the j*bs * fix: use cache dir directly * fix: remove "**.c++" and "**.h++" * fix: remove `.yml` extension from local actions * fix: composite actions should use composite syntax * fix: move build-meson back into composite * fix: add `nix_path` to nix install step * fix: move composite workflows into `.github/actions` * fix: move actions into a directory name after them and then rename them to action * fix: add a shell for each run step * fix: use single-quote strings in interpolation * fix: use nix as the shell for compilation * make `build-linux` use `flake.nix` * fix: `on pull_request` not `on pull-request` * fix: shouldn't declare paths for a list * fix: typo in release job build path * fix: move ccache dir creation to `restore-cache.yml` * fix: `runner.temp` should be `RUNNER_TEMP` * fix: env vars should be constructed in the j*bs * fix: use cache dir directly * fix: remove "**.c++" and "**.h++" * fix: remove `.yml` extension from local actions * fix: composite actions should use composite syntax * fix: move build-meson back into composite * fix: add `nix_path` to nix install step * fix: move composite workflows into `.github/actions` * fix: move actions into a directory name after them and then rename them to action * fix: add a shell for each run step * fix: use single-quote strings in interpolation * fix: use nix as the shell for compilation * fix: UI_REPEAT constant linkage * make `build-linux` use `flake.nix` * fix: `on pull_request` not `on pull-request` * fix: shouldn't declare paths for a list * fix: typo in release job build path * fix: move ccache dir creation to `restore-cache.yml` * fix: `runner.temp` should be `RUNNER_TEMP` * fix: env vars should be constructed in the j*bs * fix: use cache dir directly * fix: remove "**.c++" and "**.h++" * fix: remove `.yml` extension from local actions * fix: composite actions should use composite syntax * fix: move build-meson back into composite * fix: add `nix_path` to nix install step * fix: move composite workflows into `.github/actions` * fix: move actions into a directory name after them and then rename them to action * fix: add a shell for each run step * fix: use single-quote strings in interpolation * fix: use nix as the shell for compilation * make `build-linux` use `flake.nix` * fix: `on pull_request` not `on pull-request` * fix: shouldn't declare paths for a list * fix: typo in release job build path * fix: move ccache dir creation to `restore-cache.yml` * fix: `runner.temp` should be `RUNNER_TEMP` * fix: env vars should be constructed in the j*bs * fix: use cache dir directly * fix: remove "**.c++" and "**.h++" * fix: remove `.yml` extension from local actions * fix: composite actions should use composite syntax * fix: move build-meson back into composite * fix: add `nix_path` to nix install step * fix: move composite workflows into `.github/actions` * fix: move actions into a directory name after them and then rename them to action * fix: add a shell for each run step * fix: use single-quote strings in interpolation * fix: use nix as the shell for compilation * ci: use unity/no-unity instead of release/debug * rename build-linux jobs --------- Co-authored-by: Tropical <42101043+tropicaaal@users.noreply.github.com>
This commit is contained in:
parent
44903526c6
commit
c53e1e5905
38
.github/actions/build-meson/action.yml
vendored
Normal file
38
.github/actions/build-meson/action.yml
vendored
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
name: "Build Meson"
|
||||
description: "Builds the project using Meson"
|
||||
|
||||
inputs:
|
||||
dir_name:
|
||||
description: "The name of the directory to setup meson in"
|
||||
required: true
|
||||
type: string
|
||||
|
||||
setup_args:
|
||||
description: "The args to additionally pass to meson"
|
||||
required: false
|
||||
type: string
|
||||
|
||||
upload:
|
||||
description: "Upload the executable"
|
||||
required: false
|
||||
default: true
|
||||
type: boolean
|
||||
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- name: Setup build-directory
|
||||
shell: nix develop --command bash -e {0}
|
||||
run: meson setup ${{ inputs.dir_name }} --wipe ${{ inputs.setup_args }}
|
||||
|
||||
- name: Compile directory
|
||||
shell: nix develop --command bash -e {0}
|
||||
run: meson compile -C ${{ inputs.dir_name }} -j $(nproc) -v Minecraft.Client
|
||||
|
||||
- name: Upload executable
|
||||
if: ${{ inputs.upload }}
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: minecraft-client-linux-${{ inputs.dir_name }}-${{ github.sha }}
|
||||
path: ${{ inputs.dir_name }}/Minecraft.Client/Minecraft.Client
|
||||
retention-days: 7
|
||||
18
.github/actions/enter-devshell/action.yml
vendored
Normal file
18
.github/actions/enter-devshell/action.yml
vendored
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
name: "Enter Nix dev-shell"
|
||||
description: "Enters a Nix dev-shell"
|
||||
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- name: Install Nix
|
||||
uses: cachix/install-nix-action@v31
|
||||
with:
|
||||
nix_path: nixpkgs=channel:nixos-unstable
|
||||
|
||||
- name: Verify flake integrity
|
||||
shell: bash
|
||||
run: nix flake check
|
||||
|
||||
- name: Enter Nix dev-shell
|
||||
shell: bash
|
||||
run: nix develop
|
||||
27
.github/actions/restore-cache/action.yml
vendored
Normal file
27
.github/actions/restore-cache/action.yml
vendored
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
name: "Restore cache"
|
||||
description: "Restores the cache for ccache and Meson"
|
||||
|
||||
inputs:
|
||||
ccache_dir:
|
||||
description: "The directory used by ccache"
|
||||
required: true
|
||||
type: string
|
||||
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- name: Restore ccache cache
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ~/.ccache
|
||||
key: ${{ runner.os }}-ccache-${{ hashFiles('**/meson.build') }}
|
||||
|
||||
- name: Create ccache dir
|
||||
shell: bash
|
||||
run: mkdir -p {{ inputs.ccache_dir }}
|
||||
|
||||
- name: Restore meson cache
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ~/.cache/meson
|
||||
key: ${{ runner.os }}-meson-${{ hashFiles('**/meson.build') }}
|
||||
113
.github/workflows/build-linux.yml
vendored
113
.github/workflows/build-linux.yml
vendored
|
|
@ -1,84 +1,77 @@
|
|||
name: Build (Linux, x86-64)
|
||||
|
||||
# TODO: test with only pull-request
|
||||
on:
|
||||
push:
|
||||
paths: &workflow_paths
|
||||
- '**.cpp'
|
||||
- '**.h'
|
||||
- '**.c'
|
||||
- '**.cc'
|
||||
- '**.cxx'
|
||||
- '**.hh'
|
||||
- '**.hpp'
|
||||
- '**.hxx'
|
||||
- '**.inl'
|
||||
- "**meson.build"
|
||||
- "**.cppm"
|
||||
- "**.ixx"
|
||||
- "**.inl"
|
||||
- "**.mpp"
|
||||
- "**.ipp"
|
||||
- "**.tpp"
|
||||
- "**.txx"
|
||||
- "**.inc"
|
||||
- "**.cpp"
|
||||
- "**.hpp"
|
||||
- "**.cxx"
|
||||
- "**.hxx"
|
||||
- "**.cc"
|
||||
- "**.hh"
|
||||
- "**.c"
|
||||
- "**.h"
|
||||
- ".github/workflows/build-linux.yml"
|
||||
- "**/meson.build"
|
||||
- "flake.nix"
|
||||
- '.github/workflows/build-linux.yml'
|
||||
|
||||
pull_request:
|
||||
paths: *workflow_paths
|
||||
|
||||
workflow_dispatch:
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: ${{ !contains(github.ref, 'dev/') }}
|
||||
|
||||
jobs:
|
||||
build-linux:
|
||||
build-linux-amalgamate:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Restore .git folder
|
||||
uses: actions/cache@v5
|
||||
- uses: actions/checkout@v6
|
||||
with:
|
||||
path: .git
|
||||
key: ${{ runner.os }}-git-${{ github.sha }}
|
||||
restore-keys: ${{ runner.os }}-git-
|
||||
fetch-depth: 1
|
||||
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v6
|
||||
- name: Enter dev-shell
|
||||
uses: ./.github/actions/enter-devshell
|
||||
|
||||
- name: Install system dependencies
|
||||
uses: awalsh128/cache-apt-pkgs-action@latest
|
||||
- name: Restore build cache
|
||||
uses: ./.github/actions/restore-cache
|
||||
with:
|
||||
packages: build-essential ccache meson ninja-build libsdl2-dev libgl-dev libglu1-mesa-dev libpthread-stubs0-dev libglm-dev
|
||||
version: 1.0
|
||||
|
||||
- name: Install LLVM + libc++
|
||||
run: |
|
||||
wget -qO- https://apt.llvm.org/llvm.sh | sudo bash -s -- 20
|
||||
sudo apt-get install -y libc++-20-dev libc++abi-20-dev
|
||||
ccache_dir: ${{ runner.temp }}/ccache
|
||||
|
||||
- name: Restore ccache
|
||||
uses: actions/cache@v5
|
||||
- name: Build meson (release)
|
||||
uses: ./.github/actions/build-meson
|
||||
with:
|
||||
path: ${{ runner.temp }}/ccache
|
||||
key: ${{ runner.os }}-ccache-${{ hashFiles('**/meson.build') }}
|
||||
restore-keys: ${{ runner.os }}-ccache-
|
||||
dir_name: "build_release"
|
||||
setup_args: "-Dunity=on -Dunity_size=99999"
|
||||
|
||||
- name: Configure Meson
|
||||
env:
|
||||
CC: "ccache clang"
|
||||
CXX: "ccache clang++"
|
||||
CC_LD: lld
|
||||
CXX_LD: lld
|
||||
run: |
|
||||
meson setup build --native-file=scripts/llvm_native.txt -Dunity=off --wipe
|
||||
meson setup build_unity --native-file=scripts/llvm_native.txt -Dunity=on -Dunity_size=99999 --wipe
|
||||
build-linux-full:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
- name: Compile (-Dunity=on)
|
||||
env:
|
||||
CCACHE_DIR: ${{ runner.temp }}/ccache
|
||||
run: |
|
||||
meson compile -C build_unity -j $(nproc) -v Minecraft.Client
|
||||
|
||||
- name: Compile (-Dunity=off)
|
||||
env:
|
||||
CCACHE_DIR: ${{ runner.temp }}/ccache
|
||||
run: |
|
||||
meson compile -C build -j $(nproc) -v Minecraft.Client
|
||||
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
with:
|
||||
name: minecraft-client-linux-${{ github.sha }}
|
||||
path: build/targets/app/Minecraft.Client
|
||||
retention-days: 7
|
||||
fetch-depth: 1
|
||||
|
||||
- name: Enter dev-shell
|
||||
uses: ./.github/actions/enter-devshell
|
||||
|
||||
- name: Restore build cache
|
||||
uses: ./.github/actions/restore-cache
|
||||
with:
|
||||
ccache_dir: ${{ runner.temp }}/ccache
|
||||
|
||||
- name: Build meson (debug)
|
||||
uses: ./.github/actions/build-meson
|
||||
with:
|
||||
dir_name: "build_debug"
|
||||
setup_args: "-Dunity=off"
|
||||
|
|
|
|||
Loading…
Reference in a new issue