From b72b89db039aaf9833f7bf8382160963f629dd9b Mon Sep 17 00:00:00 2001 From: Timo Behrendt Date: Mon, 1 Apr 2024 11:52:01 +0200 Subject: [PATCH 01/12] feat: add CI pipeline --- .gitea/workflows/ci.yaml | 41 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 .gitea/workflows/ci.yaml diff --git a/.gitea/workflows/ci.yaml b/.gitea/workflows/ci.yaml new file mode 100644 index 0000000..351e15e --- /dev/null +++ b/.gitea/workflows/ci.yaml @@ -0,0 +1,41 @@ +name: CI +on: + - push + - pull_request + +env: + GOPATH: /go_path + GOCACHE: /go_cache + +jobs: + testing: + name: check and test + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 # all history for all branches and tags + - name: Setup go + uses: actions/setup-go@v5 + with: + go-version-file: go.mod + check-latest: true + - uses: https://gitea.com/actions/go-hashfiles@v0.0.1 + id: hash-go + with: + patterns: | + go.mod + go.sum + - name: cache go + id: cache-go + uses: actions/cache@v4 + with: + path: | + /go_path + /go_cache + key: go_path-${{ steps.hash-go.outputs.hash }} + - name: build + run: make build + - name: test + run: make test -- 2.49.1 From 6e30e407ca315de8add739b6d5b28e2bf67cdc54 Mon Sep 17 00:00:00 2001 From: Timo Behrendt Date: Mon, 1 Apr 2024 12:01:08 +0200 Subject: [PATCH 02/12] fix: only run CI pipeline on pull_request --- .gitea/workflows/ci.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitea/workflows/ci.yaml b/.gitea/workflows/ci.yaml index 351e15e..34fe4a5 100644 --- a/.gitea/workflows/ci.yaml +++ b/.gitea/workflows/ci.yaml @@ -1,6 +1,5 @@ name: CI on: - - push - pull_request env: -- 2.49.1 From 26f9c2b1112287987b5db32109d82fa63635d4c6 Mon Sep 17 00:00:00 2001 From: Timo Behrendt Date: Mon, 1 Apr 2024 12:54:42 +0200 Subject: [PATCH 03/12] fix: add name to cache key generation --- .gitea/workflows/ci.yaml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.gitea/workflows/ci.yaml b/.gitea/workflows/ci.yaml index 34fe4a5..f5d9633 100644 --- a/.gitea/workflows/ci.yaml +++ b/.gitea/workflows/ci.yaml @@ -20,19 +20,20 @@ jobs: with: go-version-file: go.mod check-latest: true - - uses: https://gitea.com/actions/go-hashfiles@v0.0.1 + - name: Create cache key + uses: https://gitea.com/actions/go-hashfiles@v0.0.1 id: hash-go with: patterns: | go.mod - go.sum + go.sum - name: cache go id: cache-go uses: actions/cache@v4 with: path: | /go_path - /go_cache + /go_cache key: go_path-${{ steps.hash-go.outputs.hash }} - name: build run: make build -- 2.49.1 From fea5dd02eb01a1d8db09fabce6bad10077b54710 Mon Sep 17 00:00:00 2001 From: Timo Behrendt Date: Mon, 1 Apr 2024 13:00:07 +0200 Subject: [PATCH 04/12] feat: add cache restor key --- .gitea/workflows/ci.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitea/workflows/ci.yaml b/.gitea/workflows/ci.yaml index f5d9633..011cb85 100644 --- a/.gitea/workflows/ci.yaml +++ b/.gitea/workflows/ci.yaml @@ -13,8 +13,6 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 - with: - fetch-depth: 0 # all history for all branches and tags - name: Setup go uses: actions/setup-go@v5 with: @@ -35,6 +33,8 @@ jobs: /go_path /go_cache key: go_path-${{ steps.hash-go.outputs.hash }} + restore-keys: |- + go_cache-${{ steps.hash-go.outputs.hash }} - name: build run: make build - name: test -- 2.49.1 From cc11e111e278af464c3503dcb88fc69561a8d575 Mon Sep 17 00:00:00 2001 From: Timo Behrendt Date: Mon, 1 Apr 2024 13:01:38 +0200 Subject: [PATCH 05/12] fix: add RUNNER_TOOL_CACHE --- .gitea/workflows/ci.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitea/workflows/ci.yaml b/.gitea/workflows/ci.yaml index 011cb85..97cf4ac 100644 --- a/.gitea/workflows/ci.yaml +++ b/.gitea/workflows/ci.yaml @@ -5,10 +5,11 @@ on: env: GOPATH: /go_path GOCACHE: /go_cache + RUNNER_TOOL_CACHE: /toolcache jobs: testing: - name: check and test + name: test runs-on: ubuntu-latest steps: - name: Checkout -- 2.49.1 From e9d8e07b37727652720452207a9ed56cf5500066 Mon Sep 17 00:00:00 2001 From: Timo Behrendt Date: Mon, 1 Apr 2024 13:44:56 +0200 Subject: [PATCH 06/12] feat: add lint step --- .gitea/workflows/ci.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.gitea/workflows/ci.yaml b/.gitea/workflows/ci.yaml index 97cf4ac..cf028ed 100644 --- a/.gitea/workflows/ci.yaml +++ b/.gitea/workflows/ci.yaml @@ -40,3 +40,8 @@ jobs: run: make build - name: test run: make test + - name: golangci-lint + uses: golangci/golangci-lint-action@v3 + with: + version: v1.56.2 + args: --timeout 5m \ No newline at end of file -- 2.49.1 From ffa8e73d53c3c0aba0370199a7705752dfe2e93e Mon Sep 17 00:00:00 2001 From: Timo Behrendt Date: Mon, 1 Apr 2024 14:05:28 +0200 Subject: [PATCH 07/12] Revert "feat: add lint step" This reverts commit e9d8e07b37727652720452207a9ed56cf5500066. --- .gitea/workflows/ci.yaml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.gitea/workflows/ci.yaml b/.gitea/workflows/ci.yaml index cf028ed..97cf4ac 100644 --- a/.gitea/workflows/ci.yaml +++ b/.gitea/workflows/ci.yaml @@ -40,8 +40,3 @@ jobs: run: make build - name: test run: make test - - name: golangci-lint - uses: golangci/golangci-lint-action@v3 - with: - version: v1.56.2 - args: --timeout 5m \ No newline at end of file -- 2.49.1 From 07412bf6c697bb97d27dc99e4797fe2b6ed9607c Mon Sep 17 00:00:00 2001 From: Timo Behrendt Date: Mon, 1 Apr 2024 14:50:53 +0200 Subject: [PATCH 08/12] refactor: add sharable action to setup go --- .gitea/actions/setup_go_from_cache.yaml | 43 +++++++++++++++++++++++++ .gitea/workflows/ci.yaml | 22 ++----------- 2 files changed, 45 insertions(+), 20 deletions(-) create mode 100644 .gitea/actions/setup_go_from_cache.yaml diff --git a/.gitea/actions/setup_go_from_cache.yaml b/.gitea/actions/setup_go_from_cache.yaml new file mode 100644 index 0000000..e51560c --- /dev/null +++ b/.gitea/actions/setup_go_from_cache.yaml @@ -0,0 +1,43 @@ +# Re-Usable action that setups go from cache. Can be used in e.g. workflows/ci.yaml +# setups go from cache or installs go if not found in cache +# also updates the cache + +name: setup_go_from_cache +description: 'Setup go from cache' + +inputs: + go-version-file: + description: 'Path to go version file' + required: true + check-latest: + description: 'Check for latest go version' + required: false + default: 'true' + +runs: + using: 'composite' + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup go + uses: actions/setup-go@v5 + with: + go-version-file: ${{ inputs.go-version-file }} + check-latest: ${{ inputs.check-latest }} + - name: Create cache key + id: hash-go + uses: https://gitea.com/actions/go-hashfiles@v0.0.1 + with: + patterns: | + go.mod + go.sum + - name: cache go + id: cache-go + uses: actions/cache@v4 + with: + path: | + /go_path + /go_cache + key: go_path-${{ steps.hash-go.outputs.hash }} + restore-keys: |- + go_cache-${{ steps.hash-go.outputs.hash }} diff --git a/.gitea/workflows/ci.yaml b/.gitea/workflows/ci.yaml index 97cf4ac..50eebca 100644 --- a/.gitea/workflows/ci.yaml +++ b/.gitea/workflows/ci.yaml @@ -14,28 +14,10 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 - - name: Setup go - uses: actions/setup-go@v5 + - name: setup_go_from_cache + uses: ./.gitea/actions/setup_go_from_cache with: go-version-file: go.mod - check-latest: true - - name: Create cache key - uses: https://gitea.com/actions/go-hashfiles@v0.0.1 - id: hash-go - with: - patterns: | - go.mod - go.sum - - name: cache go - id: cache-go - uses: actions/cache@v4 - with: - path: | - /go_path - /go_cache - key: go_path-${{ steps.hash-go.outputs.hash }} - restore-keys: |- - go_cache-${{ steps.hash-go.outputs.hash }} - name: build run: make build - name: test -- 2.49.1 From e27008ecb1e8e0daac2b35b8ee80cee6e31c0698 Mon Sep 17 00:00:00 2001 From: Timo Behrendt Date: Mon, 1 Apr 2024 14:52:28 +0200 Subject: [PATCH 09/12] Revert "refactor: add sharable action to setup go" This reverts commit 07412bf6c697bb97d27dc99e4797fe2b6ed9607c. --- .gitea/actions/setup_go_from_cache.yaml | 43 ------------------------- .gitea/workflows/ci.yaml | 22 +++++++++++-- 2 files changed, 20 insertions(+), 45 deletions(-) delete mode 100644 .gitea/actions/setup_go_from_cache.yaml diff --git a/.gitea/actions/setup_go_from_cache.yaml b/.gitea/actions/setup_go_from_cache.yaml deleted file mode 100644 index e51560c..0000000 --- a/.gitea/actions/setup_go_from_cache.yaml +++ /dev/null @@ -1,43 +0,0 @@ -# Re-Usable action that setups go from cache. Can be used in e.g. workflows/ci.yaml -# setups go from cache or installs go if not found in cache -# also updates the cache - -name: setup_go_from_cache -description: 'Setup go from cache' - -inputs: - go-version-file: - description: 'Path to go version file' - required: true - check-latest: - description: 'Check for latest go version' - required: false - default: 'true' - -runs: - using: 'composite' - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Setup go - uses: actions/setup-go@v5 - with: - go-version-file: ${{ inputs.go-version-file }} - check-latest: ${{ inputs.check-latest }} - - name: Create cache key - id: hash-go - uses: https://gitea.com/actions/go-hashfiles@v0.0.1 - with: - patterns: | - go.mod - go.sum - - name: cache go - id: cache-go - uses: actions/cache@v4 - with: - path: | - /go_path - /go_cache - key: go_path-${{ steps.hash-go.outputs.hash }} - restore-keys: |- - go_cache-${{ steps.hash-go.outputs.hash }} diff --git a/.gitea/workflows/ci.yaml b/.gitea/workflows/ci.yaml index 50eebca..97cf4ac 100644 --- a/.gitea/workflows/ci.yaml +++ b/.gitea/workflows/ci.yaml @@ -14,10 +14,28 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 - - name: setup_go_from_cache - uses: ./.gitea/actions/setup_go_from_cache + - name: Setup go + uses: actions/setup-go@v5 with: go-version-file: go.mod + check-latest: true + - name: Create cache key + uses: https://gitea.com/actions/go-hashfiles@v0.0.1 + id: hash-go + with: + patterns: | + go.mod + go.sum + - name: cache go + id: cache-go + uses: actions/cache@v4 + with: + path: | + /go_path + /go_cache + key: go_path-${{ steps.hash-go.outputs.hash }} + restore-keys: |- + go_cache-${{ steps.hash-go.outputs.hash }} - name: build run: make build - name: test -- 2.49.1 From cb29c4e9064e26b1004b218e63b538da85648a65 Mon Sep 17 00:00:00 2001 From: Timo Behrendt Date: Mon, 1 Apr 2024 15:12:38 +0200 Subject: [PATCH 10/12] feat: run ci pipeline on merge to main --- .gitea/workflows/ci.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitea/workflows/ci.yaml b/.gitea/workflows/ci.yaml index 97cf4ac..589487c 100644 --- a/.gitea/workflows/ci.yaml +++ b/.gitea/workflows/ci.yaml @@ -1,6 +1,9 @@ name: CI on: - pull_request + - push: + branches: + - main env: GOPATH: /go_path -- 2.49.1 From b8db8cc5adefb1f060075bcfde47dc3d8c43e231 Mon Sep 17 00:00:00 2001 From: Timo Behrendt Date: Mon, 1 Apr 2024 15:13:48 +0200 Subject: [PATCH 11/12] Revert "feat: run ci pipeline on merge to main" This reverts commit cb29c4e9064e26b1004b218e63b538da85648a65. --- .gitea/workflows/ci.yaml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.gitea/workflows/ci.yaml b/.gitea/workflows/ci.yaml index 589487c..97cf4ac 100644 --- a/.gitea/workflows/ci.yaml +++ b/.gitea/workflows/ci.yaml @@ -1,9 +1,6 @@ name: CI on: - pull_request - - push: - branches: - - main env: GOPATH: /go_path -- 2.49.1 From decb7cae07cb4833d2eba41947ec4105d088125f Mon Sep 17 00:00:00 2001 From: Timo Behrendt Date: Mon, 1 Apr 2024 15:14:08 +0200 Subject: [PATCH 12/12] feat: run ci pipeline on merge to main --- .gitea/workflows/ci.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.gitea/workflows/ci.yaml b/.gitea/workflows/ci.yaml index 97cf4ac..8d5c7d9 100644 --- a/.gitea/workflows/ci.yaml +++ b/.gitea/workflows/ci.yaml @@ -1,6 +1,9 @@ name: CI on: - - pull_request + pull_request: + push: + branches: + - main env: GOPATH: /go_path -- 2.49.1