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 5e77c97 commit ebe95f5
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 85 deletions.
112 changes: 60 additions & 52 deletions .github/workflows/pipeline.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
---
name: rdf-protect

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

defaults:
run:
shell: bash

on:
push:
branches:
Expand All @@ -23,57 +30,58 @@ jobs:
uses: actions/checkout@v4
- name: 1 - format
run: |
cat /etc/os-release
source .gitlab/scripts/before-script.sh
just nix-develop-ci just format
lint:
runs-on: ubuntu-latest
container:
image: ghcr.io/sdsc-ordes/rdf-protect:ci-lint-1.0.0
steps:
- name: Checkout
uses: actions/checkout@v4
- name: 2 - lint
run: |
source .gitlab/scripts/before-script.sh &&
just nix-develop-ci just lint
build:
runs-on: ubuntu-latest
container:
image: ghcr.io/sdsc-ordes/rdf-protect:ci-build-1.0.0
steps:
- name: Checkout
uses: actions/checkout@v4
- name: 3 - build
run: |
source .gitlab/scripts/before-script.sh &&
just nix-develop-ci just build
# - name: 3.1 - tests
# run: |
# source .gitlab/scripts/before-script.sh &&
# just nix-develop-ci just test

test:
runs-on: ubuntu-latest
container:
image: ghcr.io/sdsc-ordes/rdf-protect:ci-test-1.0.0
steps:
- name: Checkout
uses: actions/checkout@v4
- name: 4 - test
run: |
source .gitlab/scripts/before-script.sh &&
just nix-develop-ci just test
package:
runs-on: ubuntu-latest
container:
image: ghcr.io/sdsc-ordes/rdf-protect:ci-package-1.0.0
steps:
- name: Checkout
uses: actions/checkout@v4
- name: 5 - package (nix)
run: |
source .gitlab/scripts/before-script.sh &&
just build-package
# lint:
# runs-on: ubuntu-latest
# container:
# image: ghcr.io/sdsc-ordes/rdf-protect:ci-lint-1.0.0
# steps:
# - name: Checkout
# uses: actions/checkout@v4
# - name: 2 - lint
# run: |
# source .gitlab/scripts/before-script.sh &&
# just nix-develop-ci just lint
#
# build:
# runs-on: ubuntu-latest
# container:
# image: ghcr.io/sdsc-ordes/rdf-protect:ci-build-1.0.0
# steps:
# - name: Checkout
# uses: actions/checkout@v4
# - name: 3 - build
# run: |
# source .gitlab/scripts/before-script.sh &&
# just nix-develop-ci just build
# # - name: 3.1 - tests
# # run: |
# # source .gitlab/scripts/before-script.sh &&
# # just nix-develop-ci just test
#
# test:
# runs-on: ubuntu-latest
# container:
# image: ghcr.io/sdsc-ordes/rdf-protect:ci-test-1.0.0
# steps:
# - name: Checkout
# uses: actions/checkout@v4
# - name: 4 - test
# run: |
# source .gitlab/scripts/before-script.sh &&
# just nix-develop-ci just test
#
# package:
# runs-on: ubuntu-latest
# container:
# image: ghcr.io/sdsc-ordes/rdf-protect:ci-package-1.0.0
# steps:
# - name: Checkout
# uses: actions/checkout@v4
# - name: 5 - package (nix)
# run: |
# source .gitlab/scripts/before-script.sh &&
# just build-package
24 changes: 0 additions & 24 deletions .github/workflows/trigger-gitlab.yaml

This file was deleted.

31 changes: 23 additions & 8 deletions .gitlab/images/Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,34 @@ RUN apk add findutils coreutils git jq curl bash just parallel podman
# Nix Image
# ===============================================
FROM base-podman as ci-nix
ARG USER_NAME=ci
ARG USER_UID=1000
ARG USER_GID=1000
# ARG USER_HOME="/github/home"

RUN [ "TARGETPLATFORM" = "linux/amd64" ] || echo "Platform not yet supported."
COPY ./tools /container-setup/tools

# Install Nix and pre-cache the env.
RUN bash -c ". /container-setup/tools/general.sh && ci_setup_nix"
COPY rust-toolchain.toml /container-setup/
RUN cd /container-setup && \
git init && git add . && \
nix --accept-flake-config \
build --no-link "./tools/nix#devShells.x86_64-linux.ci" && \
nix store optimise

RUN git config --global safe.directory "*"

# Create user.
# RUN mkdir -p "$USER_HOME" && \
# adduser "$USER_NAME" -s /bin/zsh -D -u "$USER_UID" -g "$USER_GID" -h "$USER_HOME/$USER_NAME" && \
# mkdir -p /etc/sudoers.d && \
# echo "$USER_NAME ALL=(root) NOPASSWD:ALL" > "/etc/sudoers.d/$USER_NAME" && \
# chmod 0440 "/etc/sudoers.d/$USER_NAME" && \
# chown -R "$USER_NAME:$USER_NAME" /home /container-setup
# USER "$USER_NAME"

# COPY rust-toolchain.toml /container-setup/
# RUN cd /container-setup && \
# git init && git add . && \
# nix --accept-flake-config \
# build --no-link "./tools/nix#devShells.x86_64-linux.ci" && \
# nix store optimise

# RUN git config --global safe.directory "*"

# Format image.
# ===============================================
Expand Down
7 changes: 7 additions & 0 deletions .gitlab/scripts/before-script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,16 @@
# This script is sourced.
set -u

git config --global safe.directory "*" || {
echo "Could not overwrite safe.directory in Git config." >&2
exit 1
}

ROOT_DIR=$(git rev-parse --show-toplevel)
. "$ROOT_DIR/tools/general.sh"

print_info "Running as user: $(id)"

# ci_container_mgr_setup

unset ROOT_DIR
8 changes: 7 additions & 1 deletion tools/format-rust.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,13 @@ ROOT_DIR=$(git rev-parse --show-toplevel)
cd "$ROOT_DIR"

print_info "Run Rust format."

fmt_args=()
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 "$@"
cargo fmt "${fmt_args[@]}" "$@"

0 comments on commit ebe95f5

Please sign in to comment.