Skip to content
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

test: nixified ci times #1

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 28 additions & 64 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,72 +67,36 @@ jobs:
toolchain: ${{ env.RUST_VERSION }}
components: clippy, rustfmt

- name: Init cache
- name: Init rust cache
uses: Swatinem/rust-cache@v2

- name: Install Fuel toolchain
uses: FuelLabs/action-fuel-toolchain@v0.6.0
- name: Cache nix-cache locally
id: cache-nix
uses: actions/cache@v2.1.0
with:
toolchain: latest
date: 2023-04-12
# See https://stackoverflow.com/questions/59269850.
path: |
~/nix/store
key: ${{ runner.os }}-forc-0-39-0

- name: Check Sway formatting
run: |
cd ${{ matrix.project }}/project
forc fmt --check

- name: Check Rust formatting
run: |
cd ${{ matrix.project }}/project
cargo fmt --verbose --check

- name: Build Sway
run: |
cd ${{ matrix.project }}/project
forc build --locked

- name: Build Rust files
run: |
cd ${{ matrix.project }}/project
cargo build --locked

- name: Check Clippy Linter
run: |
cd ${{ matrix.project }}/project
cargo clippy --all-features --all-targets -- -D warnings

- name: Run Rust tests
run: |
cd ${{ matrix.project }}/project
cargo test --locked

contributing-book:
runs-on: ubuntu-latest

strategy:
matrix:
project: [".docs/contributing-book/src/code"]

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@master
- name: Install nix
uses: cachix/install-nix-action@v21
with:
toolchain: ${{ env.RUST_VERSION }}

- name: Init cache
uses: Swatinem/rust-cache@v2

- name: Install Fuel toolchain
uses: FuelLabs/action-fuel-toolchain@v0.6.0
with:
toolchain: latest
date: 2023-04-12

- name: Check Sway formatting
run: forc fmt --check --path ${{ matrix.project }}

- name: Build Sway
run: forc build --locked --path ${{ matrix.project }}
nix_path: nixpkgs=channel:nixos-unstable
extra_nix_config: |
extra-substituters = https://fuellabs.cachix.org
extra-trusted-public-keys = fuellabs.cachix.org-1:3gOmll82VDbT7EggylzOVJ6dr0jgPVU/KMN6+Kf8qx8=
Comment on lines +86 to +88
Copy link

@sdankel sdankel Jun 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From the docs: https://github.com/cachix/install-nix-action#how-do-i-add-a-binary-cache

Suggested change
extra_nix_config: |
extra-substituters = https://fuellabs.cachix.org
extra-trusted-public-keys = fuellabs.cachix.org-1:3gOmll82VDbT7EggylzOVJ6dr0jgPVU/KMN6+Kf8qx8=
extra_nix_config: |
substituters = https://fuellabs.cachix.org
trusted-public-keys = fuellabs.cachix.org-1:3gOmll82VDbT7EggylzOVJ6dr0jgPVU/KMN6+Kf8qx8=

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets try that!

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm from this docs, it looks like providing extra_ prefix to nix config tells nix to append the given public key and substituters, rather than overriding already existing ones. In this case we overriden nixos cache and made the process slower i guess. (Since we had packages found from nixos cache rather than ours but with this change we only find the packages in our cache and re-build other ones). The default substituters is https://cache.nixos.org

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need to enable experimental features here?

Copy link
Owner Author

@kayagokalp kayagokalp Jun 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the action has the flake experimental feature enabled by default, so I believe we should be good with the default settings (last bullet point in the linked section):

https://github.com/cachix/install-nix-action#features

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


- name: Install fuel toolchain
env:
CACHE_HIT: ${{ steps.cache-nix.outputs.cache-hit }}
run: |
NIX_STORE=/nix/store
if [[ "$CACHE_HIT" != 'true' ]]; then
nix profile install github:fuellabs/fuel.nix#forc-0-39-0
mkdir -p ~/nix/store
sudo cp --force --recursive $NIX_STORE/* ~/nix/store/
else
sudo mkdir -p $NIX_STORE
sudo cp --force --recursive ~/nix/store/* $NIX_STORE/
fi
Loading