Skip to content

Commit

Permalink
Merge pull request #11 from ekala-project/ci-setup
Browse files Browse the repository at this point in the history
ci: run on push to master as well
  • Loading branch information
nrdxp authored Oct 11, 2024
2 parents ff03e98 + c1aee7a commit 126bd4c
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .envrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
files=(shell.nix dev/env/shell.nix rust-toolchain.toml)
files=(shell.nix dev/env/shell.nix rust-toolchain.toml dev/npins/sources.json)

watch_file "${files[@]}"

Expand Down
34 changes: 30 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
name: CI

on:
push:
branches:
- master
pull_request:
branches:
- master

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/master' }}

jobs:
test:
runs-on: ubuntu-latest
Expand All @@ -13,11 +20,30 @@ jobs:
uses: actions/checkout@v4
- name: Install Nix
uses: nixbuild/nix-quick-install-action@v28
with:
github_access_token: ${{ secrets.PAT }}
nix_conf: |
netrc-file = /home/runner/.netrc
- uses: bcomnes/netrc-creds@v3
with:
creds: |
[
{
"machine": "github.com",
"login": "git",
"password": "${{ secrets.PAT }}"
},
{
"machine": "api.github.com",
"login": "git",
"password": "${{ secrets.PAT }}"
}
]
- name: Setup Cache
uses: DeterminateSystems/magic-nix-cache-action@v8
- name: Enter Devshell
run: . <(nix print-dev-env "$(nix-instantiate shell.nix)"
- name: Eval Devshell
run: nix-instantiate shell.nix --add-root shell
- name: Check Format
run: treefmt --ci
run: nix-shell shell --command "treefmt --ci"
- name: Run Tests
run: cargo test --all
run: nix-shell shell --command "cargo test --all"
16 changes: 12 additions & 4 deletions crates/atom/src/store/git/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,26 @@ use super::*;
use tempfile::TempDir;

pub(crate) fn init_repo_and_remote() -> Result<(TempDir, TempDir), anyhow::Error> {
use gix::actor::SignatureRef;
use gix::config::{File, Source};
let sig = SignatureRef::default();
let repo_dir = tempfile::tempdir()?;
let remote_dir = tempfile::tempdir()?;
let repo = gix::init(repo_dir.as_ref())?;
let remote = gix::init_bare(remote_dir.as_ref())?;
let no_parents: Vec<gix::ObjectId> = vec![];
let init = remote.commit(
"refs/heads/master",
let init = remote.commit_as(
sig,
sig,
"HEAD",
"init",
repo.empty_tree().id(),
no_parents.clone(),
)?;
remote.commit(
"refs/heads/master",
remote.commit_as(
sig,
sig,
"HEAD",
"2nd",
repo.empty_tree().id(),
vec![init.detach()],
Expand All @@ -26,6 +32,8 @@ pub(crate) fn init_repo_and_remote() -> Result<(TempDir, TempDir), anyhow::Error
let mut repo_remote =
repo.remote_at(format!("file://{}", remote.git_dir().display()).as_str())?;
repo_remote.save_as_to("origin", &mut config)?;
config.set_raw_value(&"user.email", "eka")?;
config.set_raw_value(&"user.name", "eka")?;
let mut file = std::fs::File::create(config_file)?;
config.write_to(&mut file)?;
Ok((repo_dir, remote_dir))
Expand Down
2 changes: 1 addition & 1 deletion dev/env/rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[toolchain]
channel = "1.80.1"
channel = "1.81.0"
components = ["clippy", "rust-analyzer", "rust-src", "rustfmt"]
targets = ["x86_64-unknown-linux-musl"]
18 changes: 9 additions & 9 deletions dev/npins/sources.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
"repo": "atom"
},
"branch": "master",
"revision": "9bd62023ed18193e1aab442abffec3490293f246",
"url": "https://github.com/ekala-project/atom/archive/9bd62023ed18193e1aab442abffec3490293f246.tar.gz",
"hash": "0j1amzb2s44g2rdrb2ra0fx135zqn41hj3h4kz63asfq9jdb71ba"
"revision": "f2f7314d0ce19a14ffac3776f9ff870e76981264",
"url": "https://github.com/ekala-project/atom/archive/f2f7314d0ce19a14ffac3776f9ff870e76981264.tar.gz",
"hash": "1ikzvrmbr10yy11igkac6f7zjn6b91rfgy75na4rf1a5fssjzgv0"
},
"fenix": {
"type": "Git",
Expand All @@ -20,9 +20,9 @@
"repo": "fenix"
},
"branch": "main",
"revision": "70c22198ab822aa93c92a7ec0933908b17131edd",
"url": "https://github.com/nix-community/fenix/archive/70c22198ab822aa93c92a7ec0933908b17131edd.tar.gz",
"hash": "0xwkdywy4cffgi9ql0mm5n255wqmhpk1r6k71rmyg19q3yc9gd8j"
"revision": "b135535125e24270dddddc8cfab455533492e4ad",
"url": "https://github.com/nix-community/fenix/archive/b135535125e24270dddddc8cfab455533492e4ad.tar.gz",
"hash": "015v4rd3bdvpn4r8i0dr2anx3zkjaqharxgf3282kamv9rajg06r"
},
"nixpkgs": {
"type": "Git",
Expand All @@ -32,9 +32,9 @@
"repo": "nixpkgs"
},
"branch": "nixpkgs-unstable",
"revision": "154bcb95ad51bc257c2ce4043a725de6ca700ef6",
"url": "https://github.com/nixos/nixpkgs/archive/154bcb95ad51bc257c2ce4043a725de6ca700ef6.tar.gz",
"hash": "0gv8wgjqldh9nr3lvpjas7sk0ffyahmvfrz5g4wd8l2r15wyk67f"
"revision": "b69de56fac8c2b6f8fd27f2eca01dcda8e0a4221",
"url": "https://github.com/nixos/nixpkgs/archive/b69de56fac8c2b6f8fd27f2eca01dcda8e0a4221.tar.gz",
"hash": "05ajl4y7a5p50siak7sjflchnx847lhf8ax5p276qrsy7lkq2i3z"
}
},
"version": 3
Expand Down

0 comments on commit 126bd4c

Please sign in to comment.