-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
This reverts commit e25e04d.
- Loading branch information
Jakub Zalewski
committed
Feb 20, 2024
1 parent
5017aae
commit 5589551
Showing
7 changed files
with
294 additions
and
28 deletions.
There are no files selected for viewing
This file contains 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,79 @@ | ||
name: Install CI deps | ||
|
||
inputs: | ||
cache-key: | ||
required: false | ||
local-cache: | ||
required: false | ||
GITHUB_TOKEN: | ||
required: true | ||
description: "GITHUB_TOKEN needed to make GitHub API requests" | ||
|
||
runs: | ||
using: "composite" | ||
|
||
steps: | ||
- name: Install Nix | ||
uses: DeterminateSystems/nix-installer-action@v8 | ||
with: | ||
github-token: ${{ inputs.GITHUB_TOKEN }} | ||
# Do not use systemd | ||
init: none | ||
|
||
- name: Set up Nix cache | ||
uses: DeterminateSystems/magic-nix-cache-action@v3 | ||
|
||
- name: Install CI deps | ||
shell: bash | ||
run: | | ||
# Remove previously installed nix profiles | ||
nix profile remove '.*' | ||
# Install the current one | ||
nix profile install .#ci-deps | ||
# Set up CI environment | ||
nix run .#ci-env >> $GITHUB_ENV | ||
- id: get-info | ||
name: Get info | ||
shell: bash | ||
run: | | ||
RUST_VERSION="$(taplo get -f rust-toolchain.toml 'toolchain.channel')" | ||
echo "cache-primary-key=toolchain-${{ runner.os }}-${{ runner.arch }}-${RUST_VERSION}" >> "$GITHUB_OUTPUT" | ||
- id: toolchain-cache-restore | ||
name: Restore Cargo Cache (Local Restore) | ||
if: ${{ inputs.local-cache }} | ||
uses: 0xmozak/local-cache/restore@ff33c7264117faa1bbd99aa0ddb467a9ccc3919e | ||
with: | ||
key: ${{ steps.get-info.outputs.cache-primary-key }} | ||
path: | | ||
~/.cargo/git | ||
~/.cargo/registry | ||
- id: toolchain-cache-save | ||
name: Persist Cargo Cache (Local Save) | ||
if: ${{ steps.toolchain-cache-restore.outputs.cache-hit != 'true' }} | ||
uses: 0xmozak/local-cache/save@ff33c7264117faa1bbd99aa0ddb467a9ccc3919e | ||
with: | ||
key: ${{ steps.get-info.outputs.cache-primary-key }} | ||
path: | | ||
~/.cargo/git | ||
~/.cargo/registry | ||
- id: local-cache | ||
name: Cache Rust artifacts (Local) | ||
uses: 0xmozak/rust-cache@d5f76b3ac4ba287ab299d4d3586d5cd11ad21cab | ||
with: | ||
prefix-key: ${{ inputs.cache-key != '' && inputs.cache-key || null }} | ||
cache-provider: "local" | ||
|
||
- name: Debug | ||
shell: bash | ||
run: echo cache-hit=${{ steps.local-cache.outputs.cache-hit }} partial-hit=${{ steps.local-cache.outputs.partial-hit }} | ||
|
||
- name: Cache Rust artifacts (Remote) | ||
uses: 0xmozak/rust-cache@d5f76b3ac4ba287ab299d4d3586d5cd11ad21cab | ||
if: ${{ steps.local-cache.outputs.cache-hit != 'true'}} | ||
with: | ||
require-full-match: ${{ steps.local-cache.outputs.partial-hit }} | ||
prefix-key: ${{ inputs.cache-key != '' && inputs.cache-key || null }} |
This file contains 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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,73 @@ | ||
{ | ||
description = "A very basic flake"; | ||
|
||
inputs = { | ||
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; | ||
flake-parts.url = "github:hercules-ci/flake-parts"; | ||
fenix = { | ||
url = "github:nix-community/fenix"; | ||
inputs.nixpkgs.follows = "nixpkgs"; | ||
}; | ||
}; | ||
|
||
outputs = inputs @ {flake-parts, ...}: | ||
flake-parts.lib.mkFlake {inherit inputs;} { | ||
systems = [ | ||
"x86_64-linux" | ||
"aarch64-darwin" | ||
]; | ||
|
||
perSystem = { | ||
config, | ||
system, | ||
pkgs, | ||
... | ||
}: { | ||
_module.args.pkgs = import inputs.nixpkgs { | ||
inherit system; | ||
|
||
overlays = [ | ||
inputs.fenix.overlays.default | ||
]; | ||
|
||
config = {}; | ||
}; | ||
|
||
formatter = pkgs.alejandra; | ||
|
||
packages.rust-toolchain = pkgs.fenix.fromToolchainFile { | ||
file = ./rust-toolchain.toml; | ||
sha256 = "sha256-/Qcw88/iUz/WDWv19OZs4zL/EpdLHsD7loh65qSXvU8="; | ||
}; | ||
|
||
packages.ci-deps = pkgs.symlinkJoin { | ||
name = "ci-deps"; | ||
|
||
paths = with pkgs; | ||
[ | ||
taplo | ||
nodejs_20 | ||
wasmtime | ||
cargo-nextest | ||
config.packages.rust-toolchain | ||
] | ||
++ lib.lists.optional (stdenv.isDarwin) pkgs.darwin.libiconv; | ||
}; | ||
|
||
# CI Setup for GitHub Actions | ||
packages.ci-env = pkgs.writeScriptBin "ci-setup" '' | ||
echo CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUSTFLAGS="-C link-args=-Wl,-rpath,${config.packages.ci-deps}/lib/" | ||
echo CARGO_TARGET_AARCH64_APPLE_DARWIN_RUSTFLAGS="-C link-args=-Wl,-rpath,${config.packages.ci-deps}/lib/" | ||
''; | ||
|
||
devShells.default = pkgs.mkShell { | ||
nativeBuildInputs = [ | ||
config.packages.ci-deps | ||
]; | ||
|
||
CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUSTFLAGS = ''-C link-args=-Wl,-rpath,${config.packages.ci-deps}/lib/''; | ||
CARGO_TARGET_AARCH64_APPLE_DARWIN_RUSTFLAGS = ''-C link-args=-Wl,-rpath,${config.packages.ci-deps}/lib/''; | ||
}; | ||
}; | ||
}; | ||
} |
Oops, something went wrong.