Skip to content

Commit

Permalink
Implement CI
Browse files Browse the repository at this point in the history
  • Loading branch information
MaeIsBad committed Sep 13, 2024
1 parent c8478d7 commit 0f89634
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 5 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: "Test"
on:
pull_request:
push:
jobs:
get-flake-checks:
runs-on: ubuntu-latest
outputs:
flake-checks: "${{ steps.set-outputs.outputs.checks }}"
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v27
- uses: DeterminateSystems/magic-nix-cache-action@v2
run: >
nix flake show --json
| jq -rc '.checks["x86_64-linux"]
| keys' >> "flake-checks"
- id: set-outputs
run: echo "checks=$(cat flake-checks)" >> "$GITHUB_OUTPUT"

build:
runs-on: ubuntu-latest
outputs:
flake-checks: "${{ steps.set-outputs.outputs.checks }}"
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v27
- uses: DeterminateSystems/magic-nix-cache-action@v2
- run: nix build

flake-checks:
runs-on: ubuntu-latest
needs: [ flake-checks, build ]
strategy:
matrix:
check: ${{ fromJSON(needs.get-flake-checks.outputs.flake-checks) }}
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v27
- uses: DeterminateSystems/magic-nix-cache-action@v2
- run: nix build -L ".#checks.$check"
env:
check: "${{ matrix.check }}"
10 changes: 5 additions & 5 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -68,27 +68,27 @@
# Note that this is done as a separate derivation so that
# we can block the CI if there are issues here, but not
# prevent downstream consumers from building our crate by itself.
webkit-pdf-inator-clippy = craneLib.cargoClippy (commonArgs // {
cargo-clippy = craneLib.cargoClippy (commonArgs // {
inherit cargoArtifacts;
cargoClippyExtraArgs = "--all-targets -- --deny warnings";
});

webkit-pdf-inator-doc = craneLib.cargoDoc (commonArgs // {
cargo-doc = craneLib.cargoDoc (commonArgs // {
inherit cargoArtifacts;
});

webkit-pdf-inator-fmt = craneLib.cargoFmt {
cargo-fmt = craneLib.cargoFmt {
inherit src;
};

webkit-pdf-inator-deny = craneLib.cargoDeny {
cargo-deny = craneLib.cargoDeny {
inherit src;
};

# Run tests with cargo-nextest
# Consider setting `doCheck = false` on `webkit-pdf-inator` if you do not want
# the tests to run twice
webkit-pdf-inator-nextest = craneLib.cargoNextest (commonArgs // {
nextest = craneLib.cargoNextest (commonArgs // {
inherit cargoArtifacts;
partitions = 1;
partitionType = "count";
Expand Down
8 changes: 8 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,11 @@ fn main() -> glib::ExitCode {
});
app.run()
}

#[cfg(test)]
mod test {
#[test]
fn test_add() {
assert_eq!(1 + 2, 3);
}
}

0 comments on commit 0f89634

Please sign in to comment.