From 4e63bba4fe9484fe508694bfad92adbaa9c0cb7e Mon Sep 17 00:00:00 2001 From: Kristoffer Dalby Date: Sun, 30 Jan 2022 08:55:41 +0000 Subject: [PATCH 1/6] Only compat go 1.17 in go mod tidy --- .goreleaser.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.goreleaser.yml b/.goreleaser.yml index 5073b57..a492860 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -2,7 +2,7 @@ # Make sure to check the documentation at http://goreleaser.com before: hooks: - - go mod tidy + - go mod tidy -compat=1.17 release: prerelease: auto From e0c22a414b0dac1f3fa698c1f3170df554af235b Mon Sep 17 00:00:00 2001 From: Kristoffer Dalby Date: Sun, 30 Jan 2022 08:56:28 +0000 Subject: [PATCH 2/6] Remove wrong comment --- .goreleaser.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.goreleaser.yml b/.goreleaser.yml index a492860..b240ab0 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -1,5 +1,4 @@ -# This is an example .goreleaser.yml file with some sane defaults. -# Make sure to check the documentation at http://goreleaser.com +--- before: hooks: - go mod tidy -compat=1.17 From 71ab4c9b2cce7c2aaf4fbc14181c7551b98c4e3c Mon Sep 17 00:00:00 2001 From: Kristoffer Dalby Date: Sun, 30 Jan 2022 08:59:25 +0000 Subject: [PATCH 3/6] Fix type according to config schema --- .goreleaser.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.goreleaser.yml b/.goreleaser.yml index b240ab0..d1dec26 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -32,7 +32,7 @@ builds: goarch: - arm goarm: - - 7 + - "7" env: - CC=arm-linux-gnueabihf-gcc - CXX=arm-linux-gnueabihf-g++ From 1815040d9821cd2ced960e1c21ca9b867d7ab10c Mon Sep 17 00:00:00 2001 From: Kristoffer Dalby Date: Sun, 30 Jan 2022 09:43:48 +0000 Subject: [PATCH 4/6] Set up build build avoidance This commit configures the CI to run specific parts of the CI when relevant changes has been made. This should help us not have to deal with the integration tests when we do doc/admin changes. --- .github/workflows/lint.yml | 26 ++++++++++++++++++++++++++ .github/workflows/test-integration.yml | 17 ++++++++++++----- .github/workflows/test.yml | 22 +++++++++++++++------- 3 files changed, 53 insertions(+), 12 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 6fb985f..65b37f5 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -9,7 +9,18 @@ jobs: steps: - uses: actions/checkout@v2 + - name: Get changed files + id: changed-files + uses: tj-actions/changed-files@v14.1 + with: + files: | + go.* + **/*.go + integration_test/ + config-example.yaml + - name: golangci-lint + if: steps.changed-files.outputs.any_changed == 'true' uses: golangci/golangci-lint-action@v2 with: version: latest @@ -25,6 +36,21 @@ jobs: steps: - uses: actions/checkout@v2 + - name: Get changed files + id: changed-files + uses: tj-actions/changed-files@v14.1 + with: + files: | + **/*.md + **/*.yml + **/*.yaml + **/*.ts + **/*.js + **/*.sass + **/*.css + **/*.scss + **/*.html + - name: Prettify code uses: creyD/prettier_action@v4.0 with: diff --git a/.github/workflows/test-integration.yml b/.github/workflows/test-integration.yml index d4179ea..c061370 100644 --- a/.github/workflows/test-integration.yml +++ b/.github/workflows/test-integration.yml @@ -3,21 +3,28 @@ name: CI on: [pull_request] jobs: - # The "build" workflow integration-test: - # The type of runner that the job will run on runs-on: ubuntu-latest - # Steps represent a sequence of tasks that will be executed as part of the job steps: - # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - uses: actions/checkout@v2 - # Setup Go + - name: Get changed files + id: changed-files + uses: tj-actions/changed-files@v14.1 + with: + files: | + go.* + **/*.go + integration_test/ + config-example.yaml + - name: Setup Go + if: steps.changed-files.outputs.any_changed == 'true' uses: actions/setup-go@v2 with: go-version: "1.17" - name: Run Integration tests + if: steps.changed-files.outputs.any_changed == 'true' run: go test -tags integration -timeout 30m diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 651063f..6f8ac08 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -3,31 +3,39 @@ name: CI on: [push, pull_request] jobs: - # The "build" workflow test: - # The type of runner that the job will run on runs-on: ubuntu-latest - # Steps represent a sequence of tasks that will be executed as part of the job steps: - # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - uses: actions/checkout@v2 - # Setup Go + - name: Get changed files + id: changed-files + uses: tj-actions/changed-files@v14.1 + with: + files: | + go.* + **/*.go + integration_test/ + config-example.yaml + - name: Setup Go + if: steps.changed-files.outputs.any_changed == 'true' uses: actions/setup-go@v2 with: - go-version: "1.17" # The Go version to download (if necessary) and use. + go-version: "1.17" - # Install all the dependencies - name: Install dependencies + if: steps.changed-files.outputs.any_changed == 'true' run: | go version sudo apt update sudo apt install -y make - name: Run tests + if: steps.changed-files.outputs.any_changed == 'true' run: make test - name: Run build + if: steps.changed-files.outputs.any_changed == 'true' run: make From 991175f2aa36fb6a7f99d029cde6b1cf039cab36 Mon Sep 17 00:00:00 2001 From: Kristoffer Dalby Date: Sun, 30 Jan 2022 09:49:15 +0000 Subject: [PATCH 5/6] Add depth and avoidance for build --- .github/workflows/build.yml | 15 +++++++++++++++ .github/workflows/lint.yml | 3 +++ .github/workflows/test-integration.yml | 1 + .github/workflows/test.yml | 1 + 4 files changed, 20 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 589d8c5..b8ea7d6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -15,21 +15,36 @@ jobs: steps: - uses: actions/checkout@v2 + - name: Get changed files + id: changed-files + uses: tj-actions/changed-files@v14.1 + with: + fetch-depth: 2 + files: | + go.* + **/*.go + integration_test/ + config-example.yaml + - name: Setup Go + if: steps.changed-files.outputs.any_changed == 'true' uses: actions/setup-go@v2 with: go-version: "1.17" - name: Install dependencies + if: steps.changed-files.outputs.any_changed == 'true' run: | go version sudo apt update sudo apt install -y make - name: Run build + if: steps.changed-files.outputs.any_changed == 'true' run: make build - uses: actions/upload-artifact@v2 + if: steps.changed-files.outputs.any_changed == 'true' with: name: headscale-linux path: headscale diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 65b37f5..1c0e86d 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -13,6 +13,7 @@ jobs: id: changed-files uses: tj-actions/changed-files@v14.1 with: + fetch-depth: 2 files: | go.* **/*.go @@ -40,6 +41,7 @@ jobs: id: changed-files uses: tj-actions/changed-files@v14.1 with: + fetch-depth: 2 files: | **/*.md **/*.yml @@ -52,6 +54,7 @@ jobs: **/*.html - name: Prettify code + if: steps.changed-files.outputs.any_changed == 'true' uses: creyD/prettier_action@v4.0 with: prettier_options: >- diff --git a/.github/workflows/test-integration.yml b/.github/workflows/test-integration.yml index c061370..f6eb7b4 100644 --- a/.github/workflows/test-integration.yml +++ b/.github/workflows/test-integration.yml @@ -13,6 +13,7 @@ jobs: id: changed-files uses: tj-actions/changed-files@v14.1 with: + fetch-depth: 2 files: | go.* **/*.go diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6f8ac08..c285946 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -13,6 +13,7 @@ jobs: id: changed-files uses: tj-actions/changed-files@v14.1 with: + fetch-depth: 2 files: | go.* **/*.go From 0862f60ff05546a995bf68322b159900c4635c73 Mon Sep 17 00:00:00 2001 From: Kristoffer Dalby Date: Sun, 30 Jan 2022 09:54:26 +0000 Subject: [PATCH 6/6] Put depth in the correct place --- .github/workflows/build.yml | 3 ++- .github/workflows/lint.yml | 6 ++++-- .github/workflows/test-integration.yml | 3 ++- .github/workflows/test.yml | 3 ++- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b8ea7d6..d92e9e6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -14,12 +14,13 @@ jobs: steps: - uses: actions/checkout@v2 + with: + fetch-depth: 2 - name: Get changed files id: changed-files uses: tj-actions/changed-files@v14.1 with: - fetch-depth: 2 files: | go.* **/*.go diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 1c0e86d..26a24ae 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -8,12 +8,13 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 + with: + fetch-depth: 2 - name: Get changed files id: changed-files uses: tj-actions/changed-files@v14.1 with: - fetch-depth: 2 files: | go.* **/*.go @@ -36,12 +37,13 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 + with: + fetch-depth: 2 - name: Get changed files id: changed-files uses: tj-actions/changed-files@v14.1 with: - fetch-depth: 2 files: | **/*.md **/*.yml diff --git a/.github/workflows/test-integration.yml b/.github/workflows/test-integration.yml index f6eb7b4..9f526f9 100644 --- a/.github/workflows/test-integration.yml +++ b/.github/workflows/test-integration.yml @@ -8,12 +8,13 @@ jobs: steps: - uses: actions/checkout@v2 + with: + fetch-depth: 2 - name: Get changed files id: changed-files uses: tj-actions/changed-files@v14.1 with: - fetch-depth: 2 files: | go.* **/*.go diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c285946..9ce8a77 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -8,12 +8,13 @@ jobs: steps: - uses: actions/checkout@v2 + with: + fetch-depth: 2 - name: Get changed files id: changed-files uses: tj-actions/changed-files@v14.1 with: - fetch-depth: 2 files: | go.* **/*.go