From 6dfc0cdd228e8a0c25ae2a3fcfbf18e485b76adb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20N=C3=BCtzi?= Date: Tue, 25 Jun 2024 23:17:38 +0200 Subject: [PATCH] ci: Fix Github workflows --- .github/workflows/pipeline.yaml | 47 +++++++++++++++++---------- .github/workflows/trigger-gitlab.yaml | 24 ++++++++++++++ .gitlab/pipeline.yaml | 20 ++++++------ .gitlab/scripts/before-script.sh | 2 +- justfile | 17 +++++++--- 5 files changed, 78 insertions(+), 32 deletions(-) create mode 100644 .github/workflows/trigger-gitlab.yaml diff --git a/.github/workflows/pipeline.yaml b/.github/workflows/pipeline.yaml index 9c681ae..f6acd05 100644 --- a/.github/workflows/pipeline.yaml +++ b/.github/workflows/pipeline.yaml @@ -1,24 +1,37 @@ name: rdf-protect -on: [push] +on: + push: + branches: + - main + - "feat/*" + - "fix/*" + + pull_request: + branches: + - main jobs: - trigger-gitlab: + format: + runs-on: ubuntu-latest + container: + image: ghcr.io/sdsc-ordes/rdf-protect:ci-format-1.0.0 + steps: + - source .gitlab/scripts/before-script.sh && + just nix-develop-ci just format + + lint: runs-on: ubuntu-latest - environment: "CI Gitlab" + container: + image: ghcr.io/sdsc-ordes/rdf-protect:ci-lint-1.0.0 steps: - - name: Checkout - uses: actions/checkout@v4 + - source .gitlab/scripts/before-script.sh && + just nix-develop-ci just lint - - name: Mirror + Trigger CI - uses: SvanBoxel/gitlab-mirror-and-ci-action@master - with: - args: "https://gitlab.datascience.ch/gabriel.nuetzi/rdf-protect" - env: - FOLLOW_TAGS: "true" - FORCE_PUSH: "true" - GITLAB_HOSTNAME: "gitlab.datascience.ch" - GITLAB_USERNAME: ${{ secrets.GITLAB_USERNAME }} - GITLAB_PASSWORD: ${{ secrets.GITLAB_PASSWORD }} - GITLAB_PROJECT_ID: "454" - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + build: + runs-on: ubuntu-latest + container: + image: ghcr.io/sdsc-ordes/rdf-protect:ci-build-1.0.0 + steps: + - source .gitlab/scripts/before-script.sh && + just nix-develop-ci just lint diff --git a/.github/workflows/trigger-gitlab.yaml b/.github/workflows/trigger-gitlab.yaml new file mode 100644 index 0000000..9c681ae --- /dev/null +++ b/.github/workflows/trigger-gitlab.yaml @@ -0,0 +1,24 @@ +name: rdf-protect + +on: [push] + +jobs: + trigger-gitlab: + runs-on: ubuntu-latest + environment: "CI Gitlab" + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Mirror + Trigger CI + uses: SvanBoxel/gitlab-mirror-and-ci-action@master + with: + args: "https://gitlab.datascience.ch/gabriel.nuetzi/rdf-protect" + env: + FOLLOW_TAGS: "true" + FORCE_PUSH: "true" + GITLAB_HOSTNAME: "gitlab.datascience.ch" + GITLAB_USERNAME: ${{ secrets.GITLAB_USERNAME }} + GITLAB_PASSWORD: ${{ secrets.GITLAB_PASSWORD }} + GITLAB_PROJECT_ID: "454" + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitlab/pipeline.yaml b/.gitlab/pipeline.yaml index 7ff4d84..0c549b0 100644 --- a/.gitlab/pipeline.yaml +++ b/.gitlab/pipeline.yaml @@ -12,26 +12,26 @@ stages: - if: "$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH" when: always -lint: - stage: lint +format: + stage: format needs: [] - image: ghcr.io/sdsc-ordes/rdf-protect:ci-lint-1.0.0 + image: ghcr.io/sdsc-order/rdf-protect:ci-format-1.0.0 rules: - *defaults-rules script: - source .gitlab/scripts/before-script.sh - - nix develop .#ci --command just lint + - just nix-develop-ci just format-general + - just nix-develop-ci just format -format: - stage: format +lint: + stage: lint needs: [] - image: ghcr.io/sdsc-order/rdf-protect:ci-format-1.0.0 + image: ghcr.io/sdsc-ordes/rdf-protect:ci-lint-1.0.0 rules: - *defaults-rules script: - source .gitlab/scripts/before-script.sh - - nix develop .#ci --command just format-general - - nix develop .#ci --command just format + - just nix-develop-ci just lint build: stage: build @@ -41,4 +41,4 @@ build: - *defaults-rules script: - source .gitlab/scripts/before-script.sh - - nix develop .#ci --command just build + - just nix-develop-ci just build diff --git a/.gitlab/scripts/before-script.sh b/.gitlab/scripts/before-script.sh index 8bd981d..0d6c06f 100755 --- a/.gitlab/scripts/before-script.sh +++ b/.gitlab/scripts/before-script.sh @@ -6,6 +6,6 @@ set -u ROOT_DIR=$(git rev-parse --show-toplevel) . "$ROOT_DIR/tools/general.sh" -ci_container_mgr_setup +# ci_container_mgr_setup unset ROOT_DIR diff --git a/justfile b/justfile index acc66c8..07a633b 100644 --- a/justfile +++ b/justfile @@ -11,6 +11,7 @@ container_mgr := "podman" nix-develop shell="zsh": cd "{{root_dir}}" && nix develop ./tools/nix#default --command zsh + # Build the executable. build *args: cd "{{root_dir}}" && cargo build "${@:1}" @@ -23,18 +24,26 @@ watch: run: cd "{{root_dir}}" && cargo run "${@:1}" -format-general *args: - # Not implemented yet. - true - +# Format the code. format *args: cd "{{comp_dir}}" && \ "{{root_dir}}/tools/format-rust.sh" {{args}} +# Format all files other files. +format-general *args: + # Not implemented yet. + true + +# Lint all code. lint *args: cd "{{comp_dir}}" && \ "{{root_dir}}/tools/lint-rust.sh" {{args}} +# Upload all images for CI. upload-ci-images: cd "{{root_dir}}" && \ .gitlab/scripts/upload-images.sh + +# Enter a Nix development shell for CI. +nix-develop-ci: + cd "{{root_dir}}" && nix develop ./tools/nix#default --command "$@"