Skip to content

Commit

Permalink
Refactor CI setup
Browse files Browse the repository at this point in the history
  • Loading branch information
AlphaKeks committed Jan 10, 2025
1 parent 757c436 commit f857870
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 69 deletions.
46 changes: 10 additions & 36 deletions .github/workflows/check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
# - fmt: checks that the code is formatted according to rustfmt
# - clippy: checks that the code does not contain any clippy warnings

name: check
name: Checks

permissions:
contents: read

on:
push:
branches: ['master', 'take1337']
branches: ['master']
pull_request:

# If new code is pushed to a PR branch, then cancel in progress workflows for that PR.
Expand All @@ -19,40 +19,14 @@ concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

env:
CARGO_TERM_COLOR: 'always'
SQLX_OFFLINE: '1'

jobs:
clippy:
name: clippy
runs-on: ubuntu-latest
permissions:
contents: read
checks: write
strategy:
fail-fast: false
steps:
- uses: actions/checkout@v4
- name: Install Rust Nightly
uses: dtolnay/rust-toolchain@nightly
with:
components: clippy
- uses: Swatinem/rust-cache@v2
- name: cargo clippy
run: |
cargo +nightly clippy --workspace --all-features --no-deps -- -Dwarnings
cargo +nightly clippy --workspace --tests --no-deps -- -Dwarnings
rustfmt:
name: rustfmt
checks:
name: nix flake check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust Nightly
uses: dtolnay/rust-toolchain@nightly
with:
components: rustfmt
- uses: Swatinem/rust-cache@v2
- name: cargo fmt
run: cargo +nightly fmt --all --check
- uses: actions/checkout@v4
- uses: DeterminateSystems/nix-installer-action@main
- uses: DeterminateSystems/magic-nix-cache-action@main
- uses: DeterminateSystems/flake-checker-action@main
- name: checks
run: nix flake check .#
24 changes: 24 additions & 0 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Docker Image

permissions:
contents: read

on:
push:
branches: ['master']

jobs:
docker-image:
name: Docker Image
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: DeterminateSystems/nix-installer-action@main
- uses: DeterminateSystems/magic-nix-cache-action@main
- uses: DeterminateSystems/flake-checker-action@main
- name: checks
run: nix build .#dockerImage -o cs2kz-api.image
- uses: actions/upload-artifact@v4
with:
name: cs2kz-api.image
path: cs2kz-api.image
21 changes: 0 additions & 21 deletions .github/workflows/nix.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ permissions:

on:
push:
branches: ['master', 'take1337']
branches: ['master']

jobs:
openapi:
Expand Down
26 changes: 15 additions & 11 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,21 @@
extensions = [ "clippy" "rustfmt" ];
}));

src = craneLib.cleanCargoSource ./.;
mkFileSet = files: nixpkgs.lib.fileset.toSource {
root = ./.;
fileset = nixpkgs.lib.fileset.unions (files ++ [
(craneLib.fileset.commonCargoSources ./.)
./crates/cs2kz/migrations
./.sqlx
./.example.env
]);
};

fileSetForCrate = crate: mkFileSet [
(craneLib.fileset.commonCargoSources crate)
];

src = mkFileSet [];

commonArgs = {
inherit src;
Expand All @@ -53,16 +67,6 @@
inherit (craneLib.crateNameFromCargoToml { inherit src; }) version;
};

fileSetForCrate = crate: nixpkgs.lib.fileset.toSource {
root = ./.;
fileset = nixpkgs.lib.fileset.unions [
(craneLib.fileset.commonCargoSources ./.)
./crates/cs2kz/migrations
./.sqlx
./.example.env
];
};

cs2kz-api = craneLib.buildPackage (crateArgs // {
pname = "cs2kz-api";
src = fileSetForCrate ./crates/cs2kz-api;
Expand Down

0 comments on commit f857870

Please sign in to comment.