From 460af59783ea9aec9fc5cbd10a46352eb36a214f Mon Sep 17 00:00:00 2001 From: Cristian Oliveira Date: Thu, 10 Oct 2024 05:42:30 -0300 Subject: [PATCH] chore: use make in ci workflows (#202) --- .github/workflows/on-push-integration-test.yml | 3 --- .github/workflows/on-push-nixbuild.yml | 2 +- .github/workflows/on-push.yml | 6 +++--- .github/workflows/on-schedule-nixbuild.yml | 5 ++--- Makefile | 18 ++++++++++++++---- nix/package-from-source.nix | 12 +----------- nix/package-nightly.nix | 5 ----- 7 files changed, 21 insertions(+), 30 deletions(-) diff --git a/.github/workflows/on-push-integration-test.yml b/.github/workflows/on-push-integration-test.yml index f6ab3650..998d05ab 100644 --- a/.github/workflows/on-push-integration-test.yml +++ b/.github/workflows/on-push-integration-test.yml @@ -16,8 +16,5 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Setup env - run: mkdir /tmp/fzz - - name: Run integration tests run: make integration diff --git a/.github/workflows/on-push-nixbuild.yml b/.github/workflows/on-push-nixbuild.yml index e11851df..3b1f2b87 100644 --- a/.github/workflows/on-push-nixbuild.yml +++ b/.github/workflows/on-push-nixbuild.yml @@ -20,5 +20,5 @@ jobs: github_access_token: ${{ secrets.GITHUB_TOKEN }} - run: mkdir -p /tmp/fzz - - run: nix flake check + - run: make nix-flake-check - run: make nix-build-local diff --git a/.github/workflows/on-push.yml b/.github/workflows/on-push.yml index e93013c6..3f00a912 100644 --- a/.github/workflows/on-push.yml +++ b/.github/workflows/on-push.yml @@ -17,10 +17,10 @@ jobs: - uses: actions/checkout@v3 - name: Build - run: cargo build --verbose + run: make prebuild - name: Linter - run: cargo fmt -- --check + run: make lint - name: Run tests - run: cargo test --verbose --lib + run: make tests diff --git a/.github/workflows/on-schedule-nixbuild.yml b/.github/workflows/on-schedule-nixbuild.yml index 392beaa9..06d437b2 100644 --- a/.github/workflows/on-schedule-nixbuild.yml +++ b/.github/workflows/on-schedule-nixbuild.yml @@ -15,6 +15,5 @@ jobs: with: github_access_token: ${{ secrets.GITHUB_TOKEN }} - - run: mkdir -p /tmp/fzz - - run: nix flake check - - run: nix build .#funzzy --verbose + - run: make nix-flake-check + - run: make nix-build diff --git a/Makefile b/Makefile index 90adcc52..64372d24 100644 --- a/Makefile +++ b/Makefile @@ -4,18 +4,22 @@ help: ## Lists the available commands. Add a comment with '##' to describe a com .PHONY: tests tests: ## Execute all the tests - @cargo test $UNIT_TEST --verbose --lib + @cargo test --verbose .PHONY: build build: tests ## Execute all the tests and build funzzy binary @cargo build --release +.PHONY: prebuild +prebuild: ## Build the project in non-release mode + @cargo build + .PHONY: integration ## Exectute integration tests -integration: +integration: integration-clean @cargo test --features test-integration .PHONY: ci-integration -ci-integration: +ci-integration: integration-clean @cargo test --features test-integration .PHONY: lint @@ -31,7 +35,9 @@ install: tests ## Install funzzy on your machine .PHONY: integration-clean integration-clean: - rm -rf /tmp/fzz || sudo rm -rf /tmp/fzz + echo "Creating a temp dir for integration tests in /tmp/fzz" + rm -rf /tmp/fzz + mkdir -p /tmp/fzz .PHONY: nix-gen-patch nix-gen-patch: ## Generate a patch for the nix derivation @@ -49,6 +55,10 @@ nix-build-all: nix-build nix-build-nightly ## Build the nix derivation with the nix-build-local: ## Build the nix derivation with the local toolchain @nix build .#local --verbose -L +.PHONY: nix-build-nightly +nix-build-nightly: ## Build the nix derivation with the nightly toolchain + @nix build .# --verbose -L + .PHONY: nix-build nix-build: ## Build the nix derivation with the nightly toolchain @nix build .# --verbose -L diff --git a/nix/package-from-source.nix b/nix/package-from-source.nix index 4548bfae..b12cc2c2 100644 --- a/nix/package-from-source.nix +++ b/nix/package-from-source.nix @@ -32,17 +32,7 @@ rustPlatform.buildRustPackage { # Creating here the temporary directory in order it to be created with # the right permissions checkPhase = '' - mkdir -p /tmp/fzz - - ls -la /tmp/fzz - - touch /tmp/fzz/accepts_full_or_relativepaths.txt - touch /tmp/fzz/accepts_full_or_relativepaths2.txt - touch /tmp/fzz/accepts_full_or_relativepaths3.txt - - RUST_BACKTRACE=1 cargo test -- --nocapture - - rm -rf /tmp/fzz + RUST_BACKTRACE=1 make integration ''; # Common commands here diff --git a/nix/package-nightly.nix b/nix/package-nightly.nix index 8d9ba6da..339d27b6 100644 --- a/nix/package-nightly.nix +++ b/nix/package-nightly.nix @@ -13,11 +13,6 @@ rustPlatform.buildRustPackage rec { cargoHash = "sha256-Rs0l7361BtuhV0DsMfeyKe/ryoCZaLWBnrpuVNeRKhU="; - # When installing from source only run unit tests - checkPhase = '' - cargo test $UNIT_TEST --lib - ''; - buildInputs = lib.optionals stdenv.isDarwin [ darwin.apple_sdk.frameworks.CoreServices ];