Skip to content

Commit

Permalink
fix: ci
Browse files Browse the repository at this point in the history
  • Loading branch information
gabyx committed Jun 28, 2024
1 parent 1f35b34 commit ceea38a
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 31 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/pipeline.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ jobs:
run: |
source .gitlab/scripts/before-script.sh &&
just nix-develop just build
# - name: 3.1 - tests
# run: |
# source .gitlab/scripts/before-script.sh &&
# just nix-develop just test
- name: 3.1 - tests
run: |
source .gitlab/scripts/before-script.sh &&
just nix-develop just test
test:
runs-on: ubuntu-latest
Expand Down
20 changes: 9 additions & 11 deletions justfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
set positional-arguments
set shell := ["bash", "-cue"]
comp_dir := justfile_directory()
root_dir := `git rev-parse --show-toplevel`

# General Variables:
# You can chose either "podman" or "docker".
container_mgr := "podman"

# Deterministic steps such as `lint`, `format`
# will run
use_container := ""

# Default recipe to list all recipes.
default:
just --list
Expand Down Expand Up @@ -37,29 +40,24 @@ test:

# Format the code.
format *args:
cd "{{comp_dir}}" && \
cd "{{root_dir}}" && \
"{{root_dir}}/tools/format-rust.sh" {{args}}

# Format all files other files.
# Format all files.
format-general *args:
# Not implemented yet.
# That should run all hooks which are configured by Githooks.
true

# Lint all code.
lint *args:
cd "{{comp_dir}}" && \
cd "{{root_dir}}" && \
"{{root_dir}}/tools/lint-rust.sh" {{args}}

## ============================================================================


## CI stuff ===================================================================
# Enter a Nix development shell for CI.
nix-develop-ci:
cd "{{root_dir}}" && \
cmd=("$@") && \
{ [ -n "${cmd:-}" ] || cmd=("zsh"); } && \
cd "{{root_dir}}" && nix develop ./tools/nix#ci --command "$@"

# Build the nix package into the folder `package` (first argument).
nix-package *args:
dir="${1:-package}" && \
Expand Down
5 changes: 1 addition & 4 deletions tools/format-rust.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,4 @@ if ci_is_running; then
fmt_args+=("--check")
fi

ci_wrap_container \
ghcr.io/sdsc-ordes/rdf-protect:ci-format-1.0.0 \
nix develop ./tools/nix#ci --command \
cargo fmt "${fmt_args[@]}" "$@"
cargo fmt "${fmt_args[@]}" "$@"
12 changes: 8 additions & 4 deletions tools/general.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,17 @@ function ci_is_running() {

function ci_wrap_container() {
local container="$1"
shift 1
local nix_shell="$2"
shift 2
local cmd=("$@")

if [ "$OSTYPE" = "nixos" ]; then
"${cmd[@]}"
if command -v nix &>/dev/null; then
# Nix available, wrap over Nix shell.
nix develop "$nix_shell" --command "${cmd[@]}"
else
ci_container_mgr_run_mounted "$(pwd)" "$container" "${cmd[@]}"
# No Nix available, wrap over Nix container
ci_container_mgr_run_mounted "$(pwd)" "$container" \
nix develop "$nix_shell" --command "${cmd[@]}"
fi
}

Expand Down
10 changes: 2 additions & 8 deletions tools/lint-rust.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,9 @@ ROOT_DIR=$(git rev-parse --show-toplevel)
cd "$ROOT_DIR"

print_info "Run Rust Clippy linter."
ci_wrap_container \
ghcr.io/sdsc-ordes/rdf-protect:ci-lint-1.0.0 \
nix develop ./tools/nix#ci --command \
cargo clippy --no-deps -- -A clippy::needless_return "$@" ||
cargo clippy --no-deps -- -A clippy::needless_return "$@" ||
die "Rust clippy failed."

print_info "Run Rust Miri to check undefined behaviour."
ci_wrap_container \
ghcr.io/sdsc-ordes/rdf-protect:ci-lint-1.0.0 \
nix develop ./tools/nix#ci --command \
cargo miri test "$@" ||
cargo miri test "$@" ||
die "Rust Miri failed."

0 comments on commit ceea38a

Please sign in to comment.