From 8b9fb53ca548f5c9c5cd7e35e75700e9890ab229 Mon Sep 17 00:00:00 2001 From: Karcsesz Date: Sun, 17 Mar 2024 22:12:59 +0100 Subject: [PATCH 01/14] CI attempt: automated testing --- .forgejo/workflows/test.yml | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 .forgejo/workflows/test.yml diff --git a/.forgejo/workflows/test.yml b/.forgejo/workflows/test.yml new file mode 100644 index 0000000..aa2b729 --- /dev/null +++ b/.forgejo/workflows/test.yml @@ -0,0 +1,9 @@ +on: [push] +jobs: + test: + name: cargo test + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + - run: cargo test --all-features \ No newline at end of file -- 2.39.5 From eb6092ae7210f6a9e853dca460888589de87529a Mon Sep 17 00:00:00 2001 From: Karcsesz Date: Sun, 17 Mar 2024 22:49:30 +0100 Subject: [PATCH 02/14] Dockerfile added --- Dockerfile | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..7465352 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,23 @@ +FROM rust:latest as builder +LABEL authors="karcsesz" + +ARG target=x86_64-unknown-linux-musl + +RUN apt update && apt install -y musl-tools musl-dev +RUN update-ca-certificates +RUN rustup target add $target + +WORKDIR /fingerlink + +COPY . . + +RUN cargo build --target $target --release + +FROM scratch + +WORKDIR /fingerlink + +COPY --from=builder /fingerlink/target/x86_64-unknown-linux-musl/release/fingerlink /fingerlink/fingerlink + +ENTRYPOINT ["/fingerlink/fingerlink", "serve"] +CMD ["--help"] \ No newline at end of file -- 2.39.5 From 8dc3994648e5b635a28b1356a64995de943757f1 Mon Sep 17 00:00:00 2001 From: Karcsesz Date: Sun, 17 Mar 2024 22:52:26 +0100 Subject: [PATCH 03/14] Runs-on should be docker otherwise no runner is assigned --- .forgejo/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.forgejo/workflows/test.yml b/.forgejo/workflows/test.yml index aa2b729..f1f99ba 100644 --- a/.forgejo/workflows/test.yml +++ b/.forgejo/workflows/test.yml @@ -2,7 +2,7 @@ on: [push] jobs: test: name: cargo test - runs-on: ubuntu-latest + runs-on: docker steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable -- 2.39.5 From 5ee9cac916a4ac923649447d47a734ee485101b0 Mon Sep 17 00:00:00 2001 From: Karcsesz Date: Sun, 17 Mar 2024 23:11:43 +0100 Subject: [PATCH 04/14] Locally mirrored actions are all called actions/ --- .forgejo/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.forgejo/workflows/test.yml b/.forgejo/workflows/test.yml index f1f99ba..7d3ee34 100644 --- a/.forgejo/workflows/test.yml +++ b/.forgejo/workflows/test.yml @@ -5,5 +5,5 @@ jobs: runs-on: docker steps: - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@stable + - uses: actions/rust-toolchain@stable - run: cargo test --all-features \ No newline at end of file -- 2.39.5 From 64cb3f9861354dce33cee76a9aba8e4df4653be4 Mon Sep 17 00:00:00 2001 From: Karcsesz Date: Mon, 18 Mar 2024 00:17:53 +0100 Subject: [PATCH 05/14] Docker image question mark? --- .forgejo/workflows/test.yml | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/.forgejo/workflows/test.yml b/.forgejo/workflows/test.yml index 7d3ee34..5139252 100644 --- a/.forgejo/workflows/test.yml +++ b/.forgejo/workflows/test.yml @@ -6,4 +6,16 @@ jobs: steps: - uses: actions/checkout@v4 - uses: actions/rust-toolchain@stable - - run: cargo test --all-features \ No newline at end of file + - run: cargo test --all-features + docker: + name: docker build + runs-on: docker + steps: + - uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME}} + password: ${{ secrets.DOCKERHUB_TOKEN}} + - uses: docker/build-push-action@v5 + with: + push: true + tags: karcsesz/fingerlink:latest \ No newline at end of file -- 2.39.5 From 13a20d2dacd6aec8132310dedb0e82e614205d63 Mon Sep 17 00:00:00 2001 From: Karcsesz Date: Mon, 18 Mar 2024 00:28:37 +0100 Subject: [PATCH 06/14] docker build workflow requires ubuntu-latest --- .forgejo/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.forgejo/workflows/test.yml b/.forgejo/workflows/test.yml index 5139252..81be1a4 100644 --- a/.forgejo/workflows/test.yml +++ b/.forgejo/workflows/test.yml @@ -2,14 +2,14 @@ on: [push] jobs: test: name: cargo test - runs-on: docker + runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/rust-toolchain@stable - run: cargo test --all-features docker: name: docker build - runs-on: docker + runs-on: ubuntu-latest steps: - uses: docker/login-action@v3 with: -- 2.39.5 From 4aa7aa99f95693420811b746e0360a71e9172e50 Mon Sep 17 00:00:00 2001 From: Karcsesz Date: Mon, 18 Mar 2024 00:29:46 +0100 Subject: [PATCH 07/14] But I can only provide ubuntu-22.04 --- .forgejo/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.forgejo/workflows/test.yml b/.forgejo/workflows/test.yml index 81be1a4..6c5a509 100644 --- a/.forgejo/workflows/test.yml +++ b/.forgejo/workflows/test.yml @@ -9,7 +9,7 @@ jobs: - run: cargo test --all-features docker: name: docker build - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 steps: - uses: docker/login-action@v3 with: -- 2.39.5 From 5a02cb44c8461bcba5163688ce105bcaecbda445 Mon Sep 17 00:00:00 2001 From: Karcsesz Date: Mon, 18 Mar 2024 00:38:26 +0100 Subject: [PATCH 08/14] Switch to alpine and provide default editor --- Dockerfile | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 7465352..6353a55 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,7 +13,12 @@ COPY . . RUN cargo build --target $target --release -FROM scratch +FROM alpine:latest + +ARG editor=vim + +RUN apk add --no-cache $editor +ENV EDITOR=$editor WORKDIR /fingerlink -- 2.39.5 From 261faee7d5df53dc9e0ebb06195673ef24b2dc4d Mon Sep 17 00:00:00 2001 From: Karcsesz Date: Mon, 18 Mar 2024 00:42:32 +0100 Subject: [PATCH 09/14] Add nano as an option --- .forgejo/workflows/test.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.forgejo/workflows/test.yml b/.forgejo/workflows/test.yml index 6c5a509..4090a90 100644 --- a/.forgejo/workflows/test.yml +++ b/.forgejo/workflows/test.yml @@ -10,6 +10,8 @@ jobs: docker: name: docker build runs-on: ubuntu-22.04 + needs: + - test steps: - uses: docker/login-action@v3 with: @@ -18,4 +20,8 @@ jobs: - uses: docker/build-push-action@v5 with: push: true - tags: karcsesz/fingerlink:latest \ No newline at end of file + tags: karcsesz/fingerlink:latest + - uses: docker/build-push-action@v5 + with: + push: true + tags: karcsesz/fingerlink:latest-nano \ No newline at end of file -- 2.39.5 From 237fc1eb70836052931e5aad39c81a1494c25f7b Mon Sep 17 00:00:00 2001 From: Karcsesz Date: Mon, 18 Mar 2024 00:55:14 +0100 Subject: [PATCH 10/14] Add target dir to PATH --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 6353a55..03921b1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -19,7 +19,7 @@ ARG editor=vim RUN apk add --no-cache $editor ENV EDITOR=$editor - +ENV PATH="${PATH}:/fingerlink" WORKDIR /fingerlink COPY --from=builder /fingerlink/target/x86_64-unknown-linux-musl/release/fingerlink /fingerlink/fingerlink -- 2.39.5 From 50771d8c28ded561397a444510fedccb28027a7f Mon Sep 17 00:00:00 2001 From: Karcsesz Date: Mon, 18 Mar 2024 00:56:44 +0100 Subject: [PATCH 11/14] aaaaaaaa --- .forgejo/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.forgejo/workflows/test.yml b/.forgejo/workflows/test.yml index 4090a90..344a99f 100644 --- a/.forgejo/workflows/test.yml +++ b/.forgejo/workflows/test.yml @@ -2,7 +2,7 @@ on: [push] jobs: test: name: cargo test - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v4 - uses: actions/rust-toolchain@stable -- 2.39.5 From 5600c653efe6c365bc41803bf2d70aeb00322091 Mon Sep 17 00:00:00 2001 From: Karcsesz Date: Mon, 18 Mar 2024 01:02:54 +0100 Subject: [PATCH 12/14] Make nano actually build with nano and disable push to not get rate limited --- .forgejo/workflows/test.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.forgejo/workflows/test.yml b/.forgejo/workflows/test.yml index 344a99f..80fee57 100644 --- a/.forgejo/workflows/test.yml +++ b/.forgejo/workflows/test.yml @@ -19,9 +19,10 @@ jobs: password: ${{ secrets.DOCKERHUB_TOKEN}} - uses: docker/build-push-action@v5 with: - push: true + push: false tags: karcsesz/fingerlink:latest - uses: docker/build-push-action@v5 with: - push: true - tags: karcsesz/fingerlink:latest-nano \ No newline at end of file + push: false + tags: karcsesz/fingerlink:latest-nano + build-args: "editor=nano" \ No newline at end of file -- 2.39.5 From 63d7d34116fe22f6ffbd1c6fa17c1a43036a96db Mon Sep 17 00:00:00 2001 From: Karcsesz Date: Mon, 18 Mar 2024 01:51:52 +0100 Subject: [PATCH 13/14] Only build when target branch is main --- .forgejo/workflows/docker.yml | 24 ++++++++++++++++++++++++ .forgejo/workflows/test.yml | 19 ------------------- 2 files changed, 24 insertions(+), 19 deletions(-) create mode 100644 .forgejo/workflows/docker.yml diff --git a/.forgejo/workflows/docker.yml b/.forgejo/workflows/docker.yml new file mode 100644 index 0000000..370247f --- /dev/null +++ b/.forgejo/workflows/docker.yml @@ -0,0 +1,24 @@ +on: + push: + branches: + - main +jobs: + docker: + name: docker build + runs-on: ubuntu-22.04 + needs: + - test + steps: + - uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME}} + password: ${{ secrets.DOCKERHUB_TOKEN}} + - uses: docker/build-push-action@v5 + with: + push: true + tags: karcsesz/fingerlink:latest + - uses: docker/build-push-action@v5 + with: + push: true + tags: karcsesz/fingerlink:latest-nano + build-args: "editor=nano" \ No newline at end of file diff --git a/.forgejo/workflows/test.yml b/.forgejo/workflows/test.yml index 80fee57..72615a2 100644 --- a/.forgejo/workflows/test.yml +++ b/.forgejo/workflows/test.yml @@ -7,22 +7,3 @@ jobs: - uses: actions/checkout@v4 - uses: actions/rust-toolchain@stable - run: cargo test --all-features - docker: - name: docker build - runs-on: ubuntu-22.04 - needs: - - test - steps: - - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKERHUB_USERNAME}} - password: ${{ secrets.DOCKERHUB_TOKEN}} - - uses: docker/build-push-action@v5 - with: - push: false - tags: karcsesz/fingerlink:latest - - uses: docker/build-push-action@v5 - with: - push: false - tags: karcsesz/fingerlink:latest-nano - build-args: "editor=nano" \ No newline at end of file -- 2.39.5 From 8d7ffce13728a85c6e7ce133bd162af09b99de8b Mon Sep 17 00:00:00 2001 From: Karcsesz Date: Mon, 18 Mar 2024 01:53:21 +0100 Subject: [PATCH 14/14] Forgot that main is called master --- .forgejo/workflows/docker.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.forgejo/workflows/docker.yml b/.forgejo/workflows/docker.yml index 370247f..889f142 100644 --- a/.forgejo/workflows/docker.yml +++ b/.forgejo/workflows/docker.yml @@ -1,7 +1,7 @@ on: push: branches: - - main + - master jobs: docker: name: docker build -- 2.39.5