···99jobs:
1010 build:
1111 runs-on: ubuntu-latest
1212-1312 steps:
1413 - name: Checkout
1514 uses: actions/checkout@v3
···1817 - name: Nix Cache
1918 uses: DeterminateSystems/magic-nix-cache-action@main
20192121- - name: Build Cmprss
2222- run: nix build
2020+ - name: Format
2121+ run: nix build .#fmt
2222+2323+ - name: Format non-Rust
2424+ run: nix build .#checks.x86_64-linux.treefmt
2525+2626+ - name: Audit
2727+ run: nix build .#audit
2828+2929+ - name: Clippy
3030+ run: nix build .#clippy
3131+3232+ - name: Build docs
3333+ run: nix build .#doc
3434+3535+ - name: Test
3636+ run: nix build .#test
3737+3838+ - name: Build cmprss
3939+ run: nix build .#cmprss
4040+4141+ # Run any nix checks that aren't covered by the above
4242+ # This should evaluate the nix expression and then do nothing
4343+ - name: Forgotten checks
4444+ run: nix flake check
23452424- # Runs all the other checks: formatting, building docs, clippy, etc.
2525- - name: Nix Flake Checks
2626- # Run 1 at a time and print all the log files
2727- run: nix flake check --max-jobs 1 -L
4646+ # Run this separately since
4747+ # 1) it uses a separate set of deps, so no shared cache with the other build
4848+ # 2) failures here shouldn't block merging
4949+ coverage:
5050+ runs-on: ubuntu-latest
5151+ needs: build
5252+ steps:
5353+ - name: Checkout
5454+ uses: actions/checkout@v3
5555+ - name: Install Nix
5656+ uses: DeterminateSystems/nix-installer-action@main
5757+ - name: Nix Cache
5858+ uses: DeterminateSystems/magic-nix-cache-action@main
28592929- # If everything is successful so far, build and run test coverage
3060 - name: Build Coverage
6161+ # Build and ensure the output is linked in result/
3162 run: nix build -L .#coverage
32633364 # Upload code coverage
···3667 with:
3768 token: ${{ secrets.CODECOV_TOKEN }}
3869 file: ./result/lcov.info
3939-4040- # Run the security audit
4141- - name: Security Audit
4242- run: nix build .#audit
+4
Taskfile.yml
···8181 aliases: [cov]
8282 # Many tools don't like the file references from `nix build .#coverage`, so we need to run this outside nix
8383 cmd: cargo tarpaulin --skip-clean --include-tests --output-dir coverage --out lcov --no-default-features
8484+ nix:coverage:
8585+ desc: Create coverage using nix
8686+ cmds:
8787+ - nix build .#coverage --out-link coverage
+25-22
flake.nix
···8787 meta.mainProgram = "cmprss";
8888 });
8989 in {
9090- checks = {
9191- # Build the crate as part of `nix flake check` for convenience
9292- inherit cmprss;
9090+ packages = {
9191+ default = cmprss;
9292+ cmprss = cmprss;
9393+9494+ # Check code coverage with tarpaulin
9595+ coverage = craneLib.cargoTarpaulin (commonArgs
9696+ // {
9797+ # Use lcov output as thats far more widely supported
9898+ cargoTarpaulinExtraArgs = "--skip-clean --include-tests --output-dir $out --out lcov";
9999+ });
9310094101 # Run clippy (and deny all warnings) on the crate source
95102 clippy = craneLib.cargoClippy (commonArgs
···104111 fmt = craneLib.cargoFmt commonArgs;
105112106113 # Run tests with cargo-nextest
107107- nextest = craneLib.cargoNextest commonArgs;
114114+ test = craneLib.cargoNextest commonArgs;
115115+116116+ # Audit dependencies
117117+ # This only runs when Cargo.lock files change
118118+ audit = craneLib.cargoAudit (commonArgs
119119+ // {
120120+ inherit (inputs) advisory-db;
121121+ });
122122+ };
123123+124124+ checks = {
125125+ inherit cmprss;
126126+ # Build almost every package in checks, with exceptions:
127127+ # - coverage: It requires a full rebuild, and only needs to be run occasionally
128128+ inherit (self.packages.${system}) clippy doc fmt test audit;
108129 };
109130110131 # This also sets up `nix fmt` to run all formatters
···118139 package = toolChain;
119140 };
120141 };
121121- };
122122-123123- packages = {
124124- default = cmprss;
125125- cmprss = cmprss;
126126-127127- # Check code coverage with tarpaulin
128128- coverage = craneLib.cargoTarpaulin (commonArgs
129129- // {
130130- # Use lcov output as thats far more widely supported
131131- cargoTarpaulinExtraArgs = "--skip-clean --include-tests --output-dir $out --out lcov";
132132- });
133133-134134- # Audit dependencies
135135- audit = craneLib.cargoAudit (commonArgs
136136- // {
137137- inherit (inputs) advisory-db;
138138- });
139142 };
140143141144 apps = rec {