Fix Nix build, add Nix to CI (#840)
* Nix: Reuse input `flake-utils` in `zig-overlay` * CI/main: convert line endings from `CRLF` to `LF` * CI: Add Nix build
This commit is contained in:
parent
2717b0fba1
commit
20ba87c173
257
.github/workflows/main.yml
vendored
257
.github/workflows/main.yml
vendored
@ -1,120 +1,137 @@
|
|||||||
name: CI
|
name: CI
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
paths:
|
paths:
|
||||||
- "**.zig"
|
- "**.zig"
|
||||||
pull_request:
|
- "flake.*"
|
||||||
paths:
|
pull_request:
|
||||||
- "**.zig"
|
paths:
|
||||||
schedule:
|
- "**.zig"
|
||||||
- cron: "0 0 * * *"
|
- "flake.*"
|
||||||
workflow_dispatch:
|
schedule:
|
||||||
|
- cron: "0 0 * * *"
|
||||||
jobs:
|
workflow_dispatch:
|
||||||
build:
|
|
||||||
strategy:
|
jobs:
|
||||||
matrix:
|
build:
|
||||||
os: [ubuntu-latest, macos-latest, windows-latest]
|
strategy:
|
||||||
runs-on: ${{ matrix.os }}
|
matrix:
|
||||||
steps:
|
os: [ubuntu-latest, macos-latest, windows-latest]
|
||||||
- uses: actions/checkout@v3
|
runs-on: ${{ matrix.os }}
|
||||||
with:
|
steps:
|
||||||
fetch-depth: 0
|
- uses: actions/checkout@v3
|
||||||
submodules: true
|
with:
|
||||||
- uses: goto-bus-stop/setup-zig@v2
|
fetch-depth: 0
|
||||||
with:
|
submodules: true
|
||||||
version: master
|
- uses: goto-bus-stop/setup-zig@v2
|
||||||
|
with:
|
||||||
- run: zig version
|
version: master
|
||||||
- run: zig env
|
|
||||||
|
- run: zig version
|
||||||
- name: Build
|
- run: zig env
|
||||||
run: zig build
|
|
||||||
|
- name: Build
|
||||||
- name: Build with Tracy
|
run: zig build
|
||||||
if: ${{ matrix.os != 'macos-latest' }}
|
|
||||||
run: zig build -Denable_tracy -Denable_tracy_allocation
|
- name: Build with Tracy
|
||||||
|
if: ${{ matrix.os != 'macos-latest' }}
|
||||||
- name: Run Tests
|
run: zig build -Denable_tracy -Denable_tracy_allocation
|
||||||
run: zig build test
|
|
||||||
|
- name: Run Tests
|
||||||
- name: Build artifacts
|
run: zig build test
|
||||||
if: ${{ matrix.os == 'ubuntu-latest' }}
|
|
||||||
run: |
|
- name: Build artifacts
|
||||||
declare -a targets=("x86_64-windows" "x86_64-linux" "x86_64-macos" "x86-windows" "x86-linux" "aarch64-linux" "aarch64-macos")
|
if: ${{ matrix.os == 'ubuntu-latest' }}
|
||||||
mkdir -p "artifacts/"
|
run: |
|
||||||
|
declare -a targets=("x86_64-windows" "x86_64-linux" "x86_64-macos" "x86-windows" "x86-linux" "aarch64-linux" "aarch64-macos")
|
||||||
for target in "${targets[@]}"; do
|
mkdir -p "artifacts/"
|
||||||
mkdir -p artifacts/$target
|
|
||||||
echo "Building target ${target}..."
|
for target in "${targets[@]}"; do
|
||||||
if [ "${GITHUB_REF##*/}" == "master" ]; then
|
mkdir -p artifacts/$target
|
||||||
echo "Building safe"
|
echo "Building target ${target}..."
|
||||||
zig build -Dtarget=${target} -Drelease-safe --prefix artifacts/${target}/
|
if [ "${GITHUB_REF##*/}" == "master" ]; then
|
||||||
else
|
echo "Building safe"
|
||||||
echo "Building debug as action is not running on master"
|
zig build -Dtarget=${target} -Drelease-safe --prefix artifacts/${target}/
|
||||||
zig build -Dtarget=${target} --prefix artifacts/${target}/
|
else
|
||||||
fi
|
echo "Building debug as action is not running on master"
|
||||||
sed -e '1,5d' < README.md > artifacts/${target}/README.md
|
zig build -Dtarget=${target} --prefix artifacts/${target}/
|
||||||
cp LICENSE artifacts/${target}/
|
fi
|
||||||
done
|
sed -e '1,5d' < README.md > artifacts/${target}/README.md
|
||||||
|
cp LICENSE artifacts/${target}/
|
||||||
- name: Upload x86_64-windows artifact
|
done
|
||||||
if: ${{ matrix.os == 'ubuntu-latest' }}
|
|
||||||
uses: actions/upload-artifact@v3
|
- name: Upload x86_64-windows artifact
|
||||||
with:
|
if: ${{ matrix.os == 'ubuntu-latest' }}
|
||||||
name: zls-x86_64-windows
|
uses: actions/upload-artifact@v3
|
||||||
path: artifacts/x86_64-windows/
|
with:
|
||||||
|
name: zls-x86_64-windows
|
||||||
- name: Upload x86_64-linux artifact
|
path: artifacts/x86_64-windows/
|
||||||
if: ${{ matrix.os == 'ubuntu-latest' }}
|
|
||||||
uses: actions/upload-artifact@v3
|
- name: Upload x86_64-linux artifact
|
||||||
with:
|
if: ${{ matrix.os == 'ubuntu-latest' }}
|
||||||
name: zls-x86_64-linux
|
uses: actions/upload-artifact@v3
|
||||||
path: artifacts/x86_64-linux/
|
with:
|
||||||
|
name: zls-x86_64-linux
|
||||||
- name: Upload x86_64-macos artifact
|
path: artifacts/x86_64-linux/
|
||||||
if: ${{ matrix.os == 'ubuntu-latest' }}
|
|
||||||
uses: actions/upload-artifact@v3
|
- name: Upload x86_64-macos artifact
|
||||||
with:
|
if: ${{ matrix.os == 'ubuntu-latest' }}
|
||||||
name: zls-x86_64-macos
|
uses: actions/upload-artifact@v3
|
||||||
path: artifacts/x86_64-macos/
|
with:
|
||||||
|
name: zls-x86_64-macos
|
||||||
- name: Upload x86-windows artifact
|
path: artifacts/x86_64-macos/
|
||||||
if: ${{ matrix.os == 'ubuntu-latest' }}
|
|
||||||
uses: actions/upload-artifact@v3
|
- name: Upload x86-windows artifact
|
||||||
with:
|
if: ${{ matrix.os == 'ubuntu-latest' }}
|
||||||
name: zls-x86-windows
|
uses: actions/upload-artifact@v3
|
||||||
path: artifacts/x86-windows/
|
with:
|
||||||
|
name: zls-x86-windows
|
||||||
- name: Upload x86-linux artifact
|
path: artifacts/x86-windows/
|
||||||
if: ${{ matrix.os == 'ubuntu-latest' }}
|
|
||||||
uses: actions/upload-artifact@v3
|
- name: Upload x86-linux artifact
|
||||||
with:
|
if: ${{ matrix.os == 'ubuntu-latest' }}
|
||||||
name: zls-x86-linux
|
uses: actions/upload-artifact@v3
|
||||||
path: artifacts/x86-linux/
|
with:
|
||||||
|
name: zls-x86-linux
|
||||||
- name: Upload aarch64-linux artifact
|
path: artifacts/x86-linux/
|
||||||
if: ${{ matrix.os == 'ubuntu-latest' }}
|
|
||||||
uses: actions/upload-artifact@v3
|
- name: Upload aarch64-linux artifact
|
||||||
with:
|
if: ${{ matrix.os == 'ubuntu-latest' }}
|
||||||
name: zls-aarch64-linux
|
uses: actions/upload-artifact@v3
|
||||||
path: artifacts/aarch64-linux/
|
with:
|
||||||
|
name: zls-aarch64-linux
|
||||||
- name: Upload aarch64-macos artifact
|
path: artifacts/aarch64-linux/
|
||||||
if: ${{ matrix.os == 'ubuntu-latest' }}
|
|
||||||
uses: actions/upload-artifact@v3
|
- name: Upload aarch64-macos artifact
|
||||||
with:
|
if: ${{ matrix.os == 'ubuntu-latest' }}
|
||||||
name: zls-aarch64-macos
|
uses: actions/upload-artifact@v3
|
||||||
path: artifacts/aarch64-macos/
|
with:
|
||||||
|
name: zls-aarch64-macos
|
||||||
- name: Beam to Felix
|
path: artifacts/aarch64-macos/
|
||||||
if: ${{ matrix.os == 'ubuntu-latest' && github.ref == 'refs/heads/master' && github.repository_owner == 'zigtools' }}
|
|
||||||
uses: easingthemes/ssh-deploy@v2.1.1
|
- name: Beam to Felix
|
||||||
env:
|
if: ${{ matrix.os == 'ubuntu-latest' && github.ref == 'refs/heads/master' && github.repository_owner == 'zigtools' }}
|
||||||
SSH_PRIVATE_KEY: ${{ secrets.SERVER_SSH_PRIVKEY }}
|
uses: easingthemes/ssh-deploy@v2.1.1
|
||||||
ARGS: "-rltgoDzvO --delete"
|
env:
|
||||||
SOURCE: "artifacts/"
|
SSH_PRIVATE_KEY: ${{ secrets.SERVER_SSH_PRIVKEY }}
|
||||||
REMOTE_HOST: ${{ secrets.WEBSITE_DEPLOY_HOST }}
|
ARGS: "-rltgoDzvO --delete"
|
||||||
REMOTE_USER: ${{ secrets.WEBSITE_DEPLOY_USER }}
|
SOURCE: "artifacts/"
|
||||||
TARGET: ${{ secrets.WEBSITE_DEPLOY_FOLDER }}
|
REMOTE_HOST: ${{ secrets.WEBSITE_DEPLOY_HOST }}
|
||||||
|
REMOTE_USER: ${{ secrets.WEBSITE_DEPLOY_USER }}
|
||||||
|
TARGET: ${{ secrets.WEBSITE_DEPLOY_FOLDER }}
|
||||||
|
|
||||||
|
- name: Install Nix
|
||||||
|
if: ${{ matrix.os == 'ubuntu-latest' }}
|
||||||
|
uses: cachix/install-nix-action@v18
|
||||||
|
|
||||||
|
- name: Install Cachix
|
||||||
|
if: ${{ matrix.os == 'ubuntu-latest' }}
|
||||||
|
uses: cachix/cachix-action@v12
|
||||||
|
with:
|
||||||
|
name: zigtools
|
||||||
|
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
|
||||||
|
|
||||||
|
- name: Build Nix flake package
|
||||||
|
if: ${{ matrix.os == 'ubuntu-latest' }}
|
||||||
|
run: nix build --print-build-logs
|
||||||
|
19
flake.lock
19
flake.lock
@ -1,21 +1,6 @@
|
|||||||
{
|
{
|
||||||
"nodes": {
|
"nodes": {
|
||||||
"flake-utils": {
|
"flake-utils": {
|
||||||
"locked": {
|
|
||||||
"lastModified": 1667395993,
|
|
||||||
"narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=",
|
|
||||||
"owner": "numtide",
|
|
||||||
"repo": "flake-utils",
|
|
||||||
"rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "numtide",
|
|
||||||
"repo": "flake-utils",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"flake-utils_2": {
|
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1659877975,
|
"lastModified": 1659877975,
|
||||||
"narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=",
|
"narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=",
|
||||||
@ -110,7 +95,9 @@
|
|||||||
},
|
},
|
||||||
"zig-overlay": {
|
"zig-overlay": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"flake-utils": "flake-utils_2",
|
"flake-utils": [
|
||||||
|
"flake-utils"
|
||||||
|
],
|
||||||
"nixpkgs": [
|
"nixpkgs": [
|
||||||
"nixpkgs"
|
"nixpkgs"
|
||||||
]
|
]
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
zig-overlay.url = "github:mitchellh/zig-overlay";
|
zig-overlay.url = "github:mitchellh/zig-overlay";
|
||||||
zig-overlay.inputs.nixpkgs.follows = "nixpkgs";
|
zig-overlay.inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
zig-overlay.inputs.flake-utils.follows = "flake-utils";
|
||||||
|
|
||||||
gitignore.url = "github:hercules-ci/gitignore.nix";
|
gitignore.url = "github:hercules-ci/gitignore.nix";
|
||||||
gitignore.inputs.nixpkgs.follows = "nixpkgs";
|
gitignore.inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
Loading…
Reference in New Issue
Block a user