From 1b4e0eae947b60dc0a22c9032506b394b9a5d2ce Mon Sep 17 00:00:00 2001 From: Kimmo Lehto Date: Thu, 12 Oct 2023 10:08:02 +0300 Subject: [PATCH 1/5] Move lint actions to separate workflows Signed-off-by: Kimmo Lehto --- .github/workflows/go.yml | 6 ------ .github/workflows/golangci-lint.yml | 27 +++++++++++++++++++++++++++ .github/workflows/gomod-lint.yml | 23 +++++++++++++++++++++++ 3 files changed, 50 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/golangci-lint.yml create mode 100644 .github/workflows/gomod-lint.yml diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index c784318b..3a57abaf 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -28,12 +28,6 @@ jobs: restore-keys: | ${{ runner.os }}-go- - - name: Run golangci-lint - uses: golangci/golangci-lint-action@v3.7.0 - with: - version: latest - args: --timeout=30m - - name: Build run: make k0sctl diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml new file mode 100644 index 00000000..6764451b --- /dev/null +++ b/.github/workflows/golangci-lint.yml @@ -0,0 +1,27 @@ +name: Lint (golangci-lint) +on: + pull_request: + paths: + - '**.go' + +jobs: + golangci-lint: + name: Run golangci-lint + runs-on: ubuntu-latest + steps: + - name: Check out code into the Go module directory + uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version-file: go.mod + check-latest: true + + - name: Run golangci-lint + uses: golangci/golangci-lint-action@v3 + with: + version: latest + skip-cache: true + only-new-issues: false + args: --verbose diff --git a/.github/workflows/gomod-lint.yml b/.github/workflows/gomod-lint.yml new file mode 100644 index 00000000..91e52658 --- /dev/null +++ b/.github/workflows/gomod-lint.yml @@ -0,0 +1,23 @@ +name: Lint (go.mod/go.sum) +on: + pull_request: + paths: + - 'go.mod' + - 'go.sum' + +jobs: + gomod-lint: + name: Validate go module file consistency + runs-on: ubuntu-latest + steps: + - name: Check out code into the Go module directory + uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version-file: go.mod + check-latest: true + + - name: Check go.mod/go.sum to be consistent + run: go mod tidy -v && git diff --exit-code From 0a5672a79dfb1dfc1d6dbaa173f301278716b3f5 Mon Sep 17 00:00:00 2001 From: Kimmo Lehto Date: Thu, 12 Oct 2023 10:09:00 +0300 Subject: [PATCH 2/5] Add actionlint for checking workflows Signed-off-by: Kimmo Lehto --- .github/workflows/actionlint.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 .github/workflows/actionlint.yml diff --git a/.github/workflows/actionlint.yml b/.github/workflows/actionlint.yml new file mode 100644 index 00000000..6ca6cc5f --- /dev/null +++ b/.github/workflows/actionlint.yml @@ -0,0 +1,16 @@ +name: Lint (actionlint) +on: + pull_request: + paths: + - .github + +jobs: + actionlint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: reviewdog/action-actionlint@v1 + with: + fail_on_error: true + level: warning + github_token: ${{ github.token }} From a783cd8f228234322098c94a1315e9caaab34cab Mon Sep 17 00:00:00 2001 From: Kimmo Lehto Date: Thu, 12 Oct 2023 10:48:47 +0300 Subject: [PATCH 3/5] Move smoke-tests to a separate workflow Signed-off-by: Kimmo Lehto --- .github/workflows/go.yml | 330 +---------------------------------- .github/workflows/smoke.yml | 332 ++++++++++++++++++++++++++++++++++++ 2 files changed, 338 insertions(+), 324 deletions(-) create mode 100644 .github/workflows/smoke.yml diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 3a57abaf..3542966d 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -1,10 +1,12 @@ -name: Go +name: Go unit tests -on: [ pull_request ] +on: + pull_request: + paths: + - '**.go' jobs: - - build: + gotest: runs-on: ubuntu-20.04 steps: @@ -16,325 +18,5 @@ jobs: go-version-file: go.mod check-latest: true - - name: Go modules cache - uses: actions/cache@v3 - with: - path: | - ~/go/pkg/mod - ~/.cache/go-build - ~/Library/Caches/go-build - %LocalAppData%\go-build - key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} - restore-keys: | - ${{ runner.os }}-go- - - - name: Build - run: make k0sctl - - name: Test run: go test -v ./... - - - name: Stash the compiled binary for further testing - uses: actions/upload-artifact@v3 - with: - name: k0sctl - path: k0sctl - retention-days: 2 - - build-all: - runs-on: ubuntu-20.04 - - steps: - - uses: actions/checkout@v4 - - - name: Set up Go - uses: actions/setup-go@v4 - with: - go-version-file: go.mod - check-latest: true - - - name: Go modules cache - uses: actions/cache@v3 - with: - path: | - ~/go/pkg/mod - ~/.cache/go-build - ~/Library/Caches/go-build - %LocalAppData%\go-build - key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} - restore-keys: | - ${{ runner.os }}-go- - - - name: Build all - run: make build-all - - smoke-basic: - strategy: - matrix: - image: - - quay.io/k0sproject/bootloose-alpine3.18 - - quay.io/k0sproject/bootloose-amazonlinux2023 - - quay.io/k0sproject/bootloose-debian12 - - quay.io/k0sproject/bootloose-fedora38 - - quay.io/k0sproject/bootloose-rockylinux9 - - quay.io/k0sproject/bootloose-ubuntu20.04 - name: Basic 1+1 smoke - needs: build - runs-on: ubuntu-20.04 - - steps: - - uses: actions/checkout@v4 - - name: Set up Go - uses: actions/setup-go@v4 - with: - go-version-file: go.mod - check-latest: true - - - {"name":"Go modules cache","uses":"actions/cache@v3","with":{"path":"~/go/pkg/mod\n~/.cache/go-build\n~/Library/Caches/go-build\n%LocalAppData%\\go-build\n","key":"${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}","restore-keys":"${{ runner.os }}-go-\n"}} - - {"name":"Compiled binary cache","uses":"actions/download-artifact@v3","with":{"name":"k0sctl","path":"."}} - - {"name":"Make executable","run":"chmod +x k0sctl"} - - {"name":"K0sctl cache","uses":"actions/cache@v3","with":{"path":"/var/cache/k0sctl\n~/.cache/k0sctl\n!*.log\n","key":"k0sctl-cache"}} - - {"name":"Kubectl cache","uses":"actions/cache@v3","with":{"path":"smoke-test/kubectl\n","key":"kubectl-1.21.3"}} - - {"name":"Go modules cache","uses":"actions/cache@v3","with":{"path":"~/go/pkg/mod\n~/.cache/go-build\n~/Library/Caches/go-build\n%LocalAppData%\\go-build\n","key":"${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}","restore-keys":"${{ runner.os }}-go-\n"}} - - {"name":"Docker Layer Caching For Bootloose","uses":"satackey/action-docker-layer-caching@v0.0.11","continue-on-error":true} - - - name: Run smoke tests - env: - LINUX_IMAGE: ${{ matrix.image }} - run: make smoke-basic - - smoke-basic-openssh: - strategy: - matrix: - image: - - quay.io/k0sproject/bootloose-alpine3.18 - name: Basic 1+1 smoke using openssh client - needs: build - runs-on: ubuntu-20.04 - - steps: - - uses: actions/checkout@v4 - - name: Set up Go - uses: actions/setup-go@v4 - with: - go-version-file: go.mod - check-latest: true - - - {"name":"Go modules cache","uses":"actions/cache@v3","with":{"path":"~/go/pkg/mod\n~/.cache/go-build\n~/Library/Caches/go-build\n%LocalAppData%\\go-build\n","key":"${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}","restore-keys":"${{ runner.os }}-go-\n"}} - - {"name":"Compiled binary cache","uses":"actions/download-artifact@v3","with":{"name":"k0sctl","path":"."}} - - {"name":"Make executable","run":"chmod +x k0sctl"} - - {"name":"K0sctl cache","uses":"actions/cache@v3","with":{"path":"/var/cache/k0sctl\n~/.cache/k0sctl\n!*.log\n","key":"k0sctl-cache"}} - - {"name":"Kubectl cache","uses":"actions/cache@v3","with":{"path":"smoke-test/kubectl\n","key":"kubectl-1.21.3"}} - - {"name":"Go modules cache","uses":"actions/cache@v3","with":{"path":"~/go/pkg/mod\n~/.cache/go-build\n~/Library/Caches/go-build\n%LocalAppData%\\go-build\n","key":"${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}","restore-keys":"${{ runner.os }}-go-\n"}} - - {"name":"Docker Layer Caching For Bootloose","uses":"satackey/action-docker-layer-caching@v0.0.11","continue-on-error":true} - - - name: Run smoke tests - env: - LINUX_IMAGE: ${{ matrix.image }} - run: make smoke-basic-openssh - - smoke-files: - strategy: - matrix: - image: - - quay.io/k0sproject/bootloose-ubuntu20.04 - - quay.io/k0sproject/bootloose-alpine3.18 - name: Basic file upload smoke - needs: build - runs-on: ubuntu-20.04 - - steps: - - uses: actions/checkout@v4 - - name: Set up Go - uses: actions/setup-go@v4 - with: - go-version-file: go.mod - check-latest: true - - - {"name":"Go modules cache","uses":"actions/cache@v3","with":{"path":"~/go/pkg/mod\n~/.cache/go-build\n~/Library/Caches/go-build\n%LocalAppData%\\go-build\n","key":"${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}","restore-keys":"${{ runner.os }}-go-\n"}} - - {"name":"Compiled binary cache","uses":"actions/download-artifact@v3","with":{"name":"k0sctl","path":"."}} - - {"name":"Make executable","run":"chmod +x k0sctl"} - - {"name":"K0sctl cache","uses":"actions/cache@v3","with":{"path":"/var/cache/k0sctl\n~/.cache/k0sctl\n!*.log\n","key":"k0sctl-cache"}} - - {"name":"Kubectl cache","uses":"actions/cache@v3","with":{"path":"smoke-test/kubectl\n","key":"kubectl-1.21.3"}} - - {"name":"Go modules cache","uses":"actions/cache@v3","with":{"path":"~/go/pkg/mod\n~/.cache/go-build\n~/Library/Caches/go-build\n%LocalAppData%\\go-build\n","key":"${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}","restore-keys":"${{ runner.os }}-go-\n"}} - - {"name":"Docker Layer Caching For Bootloose","uses":"satackey/action-docker-layer-caching@v0.0.11","continue-on-error":true} - - - name: Run smoke tests - run: make smoke-files - - smoke-dynamic: - strategy: - matrix: - image: - - quay.io/k0sproject/bootloose-alpine3.18 - name: Basic dynamic config smoke - needs: build - runs-on: ubuntu-20.04 - - steps: - - uses: actions/checkout@v4 - - name: Set up Go - uses: actions/setup-go@v4 - with: - go-version-file: go.mod - check-latest: true - - - {"name":"Go modules cache","uses":"actions/cache@v3","with":{"path":"~/go/pkg/mod\n~/.cache/go-build\n~/Library/Caches/go-build\n%LocalAppData%\\go-build\n","key":"${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}","restore-keys":"${{ runner.os }}-go-\n"}} - - {"name":"Compiled binary cache","uses":"actions/download-artifact@v3","with":{"name":"k0sctl","path":"."}} - - {"name":"Make executable","run":"chmod +x k0sctl"} - - {"name":"K0sctl cache","uses":"actions/cache@v3","with":{"path":"/var/cache/k0sctl\n~/.cache/k0sctl\n!*.log\n","key":"k0sctl-cache"}} - - {"name":"Kubectl cache","uses":"actions/cache@v3","with":{"path":"smoke-test/kubectl\n","key":"kubectl-1.21.3"}} - - {"name":"Go modules cache","uses":"actions/cache@v3","with":{"path":"~/go/pkg/mod\n~/.cache/go-build\n~/Library/Caches/go-build\n%LocalAppData%\\go-build\n","key":"${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}","restore-keys":"${{ runner.os }}-go-\n"}} - - {"name":"Docker Layer Caching For Bootloose","uses":"satackey/action-docker-layer-caching@v0.0.11","continue-on-error":true} - - - name: Run smoke tests - run: make smoke-dynamic - - smoke-os-override: - name: OS override smoke test - needs: build - runs-on: ubuntu-20.04 - - steps: - - uses: actions/checkout@v4 - - name: Set up Go - uses: actions/setup-go@v4 - with: - go-version-file: go.mod - check-latest: true - - - {"name":"Go modules cache","uses":"actions/cache@v3","with":{"path":"~/go/pkg/mod\n~/.cache/go-build\n~/Library/Caches/go-build\n%LocalAppData%\\go-build\n","key":"${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}","restore-keys":"${{ runner.os }}-go-\n"}} - - {"name":"Compiled binary cache","uses":"actions/download-artifact@v3","with":{"name":"k0sctl","path":"."}} - - {"name":"Make executable","run":"chmod +x k0sctl"} - - {"name":"K0sctl cache","uses":"actions/cache@v3","with":{"path":"/var/cache/k0sctl\n~/.cache/k0sctl\n!*.log\n","key":"k0sctl-cache"}} - - {"name":"Kubectl cache","uses":"actions/cache@v3","with":{"path":"smoke-test/kubectl\n","key":"kubectl-1.21.3"}} - - {"name":"Go modules cache","uses":"actions/cache@v3","with":{"path":"~/go/pkg/mod\n~/.cache/go-build\n~/Library/Caches/go-build\n%LocalAppData%\\go-build\n","key":"${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}","restore-keys":"${{ runner.os }}-go-\n"}} - - {"name":"Docker Layer Caching For Bootloose","uses":"satackey/action-docker-layer-caching@v0.0.11","continue-on-error":true} - - - name: Run OS override smoke test - run: make smoke-os-override - - smoke-upgrade: - strategy: - matrix: - image: - - quay.io/k0sproject/bootloose-alpine3.18 - - quay.io/k0sproject/bootloose-amazonlinux2023 - - quay.io/k0sproject/bootloose-rockylinux9 - - quay.io/k0sproject/bootloose-ubuntu20.04 - k0s_from: - - v1.21.6+k0s.0 - name: Upgrade - needs: build - runs-on: ubuntu-20.04 - - steps: - - uses: actions/checkout@v4 - - name: Set up Go - uses: actions/setup-go@v4 - with: - go-version-file: go.mod - check-latest: true - - - {"name":"Go modules cache","uses":"actions/cache@v3","with":{"path":"~/go/pkg/mod\n~/.cache/go-build\n~/Library/Caches/go-build\n%LocalAppData%\\go-build\n","key":"${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}","restore-keys":"${{ runner.os }}-go-\n"}} - - {"name":"Compiled binary cache","uses":"actions/download-artifact@v3","with":{"name":"k0sctl","path":"."}} - - {"name":"Make executable","run":"chmod +x k0sctl"} - - {"name":"K0sctl cache","uses":"actions/cache@v3","with":{"path":"/var/cache/k0sctl\n~/.cache/k0sctl\n!*.log\n","key":"k0sctl-cache"}} - - {"name":"Kubectl cache","uses":"actions/cache@v3","with":{"path":"smoke-test/kubectl\n","key":"kubectl-1.21.3"}} - - {"name":"Go modules cache","uses":"actions/cache@v3","with":{"path":"~/go/pkg/mod\n~/.cache/go-build\n~/Library/Caches/go-build\n%LocalAppData%\\go-build\n","key":"${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}","restore-keys":"${{ runner.os }}-go-\n"}} - - {"name":"Docker Layer Caching For Bootloose","uses":"satackey/action-docker-layer-caching@v0.0.11","continue-on-error":true} - - - name: Run smoke tests - env: - LINUX_IMAGE: ${{ matrix.image }} - K0S_FROM: ${{ matrix.k0s_from }} - run: make smoke-upgrade - - smoke-reset: - strategy: - matrix: - image: - - quay.io/k0sproject/bootloose-rockylinux9 - - quay.io/k0sproject/bootloose-ubuntu20.04 - - name: Apply + reset - needs: build - runs-on: ubuntu-20.04 - - steps: - - uses: actions/checkout@v4 - - name: Set up Go - uses: actions/setup-go@v4 - with: - go-version-file: go.mod - check-latest: true - - - {"name":"Go modules cache","uses":"actions/cache@v3","with":{"path":"~/go/pkg/mod\n~/.cache/go-build\n~/Library/Caches/go-build\n%LocalAppData%\\go-build\n","key":"${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}","restore-keys":"${{ runner.os }}-go-\n"}} - - {"name":"Compiled binary cache","uses":"actions/download-artifact@v3","with":{"name":"k0sctl","path":"."}} - - {"name":"Make executable","run":"chmod +x k0sctl"} - - {"name":"K0sctl cache","uses":"actions/cache@v3","with":{"path":"/var/cache/k0sctl\n~/.cache/k0sctl\n!*.log\n","key":"k0sctl-cache"}} - - {"name":"Kubectl cache","uses":"actions/cache@v3","with":{"path":"smoke-test/kubectl\n","key":"kubectl-1.21.3"}} - - {"name":"Go modules cache","uses":"actions/cache@v3","with":{"path":"~/go/pkg/mod\n~/.cache/go-build\n~/Library/Caches/go-build\n%LocalAppData%\\go-build\n","key":"${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}","restore-keys":"${{ runner.os }}-go-\n"}} - - {"name":"Docker Layer Caching For Bootloose","uses":"satackey/action-docker-layer-caching@v0.0.11","continue-on-error":true} - - - name: Run smoke tests - env: - LINUX_IMAGE: ${{ matrix.image }} - run: make smoke-reset - - smoke-backup-restore: - strategy: - matrix: - image: - - quay.io/k0sproject/bootloose-alpine3.18 - - quay.io/k0sproject/bootloose-rockylinux9 - - quay.io/k0sproject/bootloose-ubuntu20.04 - - name: Apply + backup + reset + restore - needs: build - runs-on: ubuntu-20.04 - - steps: - - uses: actions/checkout@v4 - - name: Set up Go - uses: actions/setup-go@v4 - with: - go-version-file: go.mod - check-latest: true - - - {"name":"Go modules cache","uses":"actions/cache@v3","with":{"path":"~/go/pkg/mod\n~/.cache/go-build\n~/Library/Caches/go-build\n%LocalAppData%\\go-build\n","key":"${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}","restore-keys":"${{ runner.os }}-go-\n"}} - - {"name":"Compiled binary cache","uses":"actions/download-artifact@v3","with":{"name":"k0sctl","path":"."}} - - {"name":"Make executable","run":"chmod +x k0sctl"} - - {"name":"K0sctl cache","uses":"actions/cache@v3","with":{"path":"/var/cache/k0sctl\n~/.cache/k0sctl\n!*.log\n","key":"k0sctl-cache"}} - - {"name":"Kubectl cache","uses":"actions/cache@v3","with":{"path":"smoke-test/kubectl\n","key":"kubectl-1.21.3"}} - - {"name":"Go modules cache","uses":"actions/cache@v3","with":{"path":"~/go/pkg/mod\n~/.cache/go-build\n~/Library/Caches/go-build\n%LocalAppData%\\go-build\n","key":"${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}","restore-keys":"${{ runner.os }}-go-\n"}} - - {"name":"Docker Layer Caching For Bootloose","uses":"satackey/action-docker-layer-caching@v0.0.11","continue-on-error":true} - - - name: Run smoke tests - env: - LINUX_IMAGE: ${{ matrix.image }} - run: make smoke-backup-restore - - smoke-init: - name: Init sub-command smoke test - needs: build - runs-on: ubuntu-20.04 - - steps: - - uses: actions/checkout@v4 - - name: Set up Go - uses: actions/setup-go@v4 - with: - go-version-file: go.mod - check-latest: true - - - {"name":"Go modules cache","uses":"actions/cache@v3","with":{"path":"~/go/pkg/mod\n~/.cache/go-build\n~/Library/Caches/go-build\n%LocalAppData%\\go-build\n","key":"${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}","restore-keys":"${{ runner.os }}-go-\n"}} - - {"name":"Compiled binary cache","uses":"actions/download-artifact@v3","with":{"name":"k0sctl","path":"."}} - - {"name":"Make executable","run":"chmod +x k0sctl"} - - {"name":"K0sctl cache","uses":"actions/cache@v3","with":{"path":"/var/cache/k0sctl\n~/.cache/k0sctl\n!*.log\n","key":"k0sctl-cache"}} - - {"name":"Kubectl cache","uses":"actions/cache@v3","with":{"path":"smoke-test/kubectl\n","key":"kubectl-1.21.3"}} - - {"name":"Go modules cache","uses":"actions/cache@v3","with":{"path":"~/go/pkg/mod\n~/.cache/go-build\n~/Library/Caches/go-build\n%LocalAppData%\\go-build\n","key":"${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}","restore-keys":"${{ runner.os }}-go-\n"}} - - {"name":"Docker Layer Caching For Bootloose","uses":"satackey/action-docker-layer-caching@v0.0.11","continue-on-error":true} - - - name: Run init smoke test - run: make smoke-init diff --git a/.github/workflows/smoke.yml b/.github/workflows/smoke.yml new file mode 100644 index 00000000..308b05f2 --- /dev/null +++ b/.github/workflows/smoke.yml @@ -0,0 +1,332 @@ +name: Smoke tests + +on: + pull_request: + paths: + - '**.go' + - Makefile + - .github + - smoke-test + +jobs: + + build: + runs-on: ubuntu-20.04 + + steps: + - uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version-file: go.mod + check-latest: true + + - name: Build + run: make k0sctl + + - name: Stash the compiled binary for further testing + uses: actions/upload-artifact@v3 + with: + name: k0sctl + path: k0sctl + retention-days: 2 + + build-all: + runs-on: ubuntu-20.04 + + steps: + - uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version-file: go.mod + check-latest: true + + - name: Go modules cache + uses: actions/cache@v3 + with: + path: | + ~/go/pkg/mod + ~/.cache/go-build + ~/Library/Caches/go-build + %LocalAppData%\go-build + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go- + + - name: Build all + run: make build-all + + smoke-basic: + strategy: + matrix: + image: + - quay.io/k0sproject/bootloose-alpine3.18 + - quay.io/k0sproject/bootloose-amazonlinux2023 + - quay.io/k0sproject/bootloose-debian12 + - quay.io/k0sproject/bootloose-fedora38 + - quay.io/k0sproject/bootloose-rockylinux9 + - quay.io/k0sproject/bootloose-ubuntu20.04 + name: Basic 1+1 smoke + needs: build + runs-on: ubuntu-20.04 + + steps: + - uses: actions/checkout@v4 + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version-file: go.mod + check-latest: true + + - {"name":"Go modules cache","uses":"actions/cache@v3","with":{"path":"~/go/pkg/mod\n~/.cache/go-build\n~/Library/Caches/go-build\n%LocalAppData%\\go-build\n","key":"${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}","restore-keys":"${{ runner.os }}-go-\n"}} + - {"name":"Compiled binary cache","uses":"actions/download-artifact@v3","with":{"name":"k0sctl","path":"."}} + - {"name":"Make executable","run":"chmod +x k0sctl"} + - {"name":"K0sctl cache","uses":"actions/cache@v3","with":{"path":"/var/cache/k0sctl\n~/.cache/k0sctl\n!*.log\n","key":"k0sctl-cache"}} + - {"name":"Kubectl cache","uses":"actions/cache@v3","with":{"path":"smoke-test/kubectl\n","key":"kubectl-1.21.3"}} + - {"name":"Go modules cache","uses":"actions/cache@v3","with":{"path":"~/go/pkg/mod\n~/.cache/go-build\n~/Library/Caches/go-build\n%LocalAppData%\\go-build\n","key":"${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}","restore-keys":"${{ runner.os }}-go-\n"}} + - {"name":"Docker Layer Caching For Bootloose","uses":"satackey/action-docker-layer-caching@v0.0.11","continue-on-error":true} + + - name: Run smoke tests + env: + LINUX_IMAGE: ${{ matrix.image }} + run: make smoke-basic + + smoke-basic-openssh: + strategy: + matrix: + image: + - quay.io/k0sproject/bootloose-alpine3.18 + name: Basic 1+1 smoke using openssh client + needs: build + runs-on: ubuntu-20.04 + + steps: + - uses: actions/checkout@v4 + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version-file: go.mod + check-latest: true + + - {"name":"Go modules cache","uses":"actions/cache@v3","with":{"path":"~/go/pkg/mod\n~/.cache/go-build\n~/Library/Caches/go-build\n%LocalAppData%\\go-build\n","key":"${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}","restore-keys":"${{ runner.os }}-go-\n"}} + - {"name":"Compiled binary cache","uses":"actions/download-artifact@v3","with":{"name":"k0sctl","path":"."}} + - {"name":"Make executable","run":"chmod +x k0sctl"} + - {"name":"K0sctl cache","uses":"actions/cache@v3","with":{"path":"/var/cache/k0sctl\n~/.cache/k0sctl\n!*.log\n","key":"k0sctl-cache"}} + - {"name":"Kubectl cache","uses":"actions/cache@v3","with":{"path":"smoke-test/kubectl\n","key":"kubectl-1.21.3"}} + - {"name":"Go modules cache","uses":"actions/cache@v3","with":{"path":"~/go/pkg/mod\n~/.cache/go-build\n~/Library/Caches/go-build\n%LocalAppData%\\go-build\n","key":"${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}","restore-keys":"${{ runner.os }}-go-\n"}} + - {"name":"Docker Layer Caching For Bootloose","uses":"satackey/action-docker-layer-caching@v0.0.11","continue-on-error":true} + + - name: Run smoke tests + env: + LINUX_IMAGE: ${{ matrix.image }} + run: make smoke-basic-openssh + + smoke-files: + strategy: + matrix: + image: + - quay.io/k0sproject/bootloose-ubuntu20.04 + - quay.io/k0sproject/bootloose-alpine3.18 + name: Basic file upload smoke + needs: build + runs-on: ubuntu-20.04 + + steps: + - uses: actions/checkout@v4 + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version-file: go.mod + check-latest: true + + - {"name":"Go modules cache","uses":"actions/cache@v3","with":{"path":"~/go/pkg/mod\n~/.cache/go-build\n~/Library/Caches/go-build\n%LocalAppData%\\go-build\n","key":"${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}","restore-keys":"${{ runner.os }}-go-\n"}} + - {"name":"Compiled binary cache","uses":"actions/download-artifact@v3","with":{"name":"k0sctl","path":"."}} + - {"name":"Make executable","run":"chmod +x k0sctl"} + - {"name":"K0sctl cache","uses":"actions/cache@v3","with":{"path":"/var/cache/k0sctl\n~/.cache/k0sctl\n!*.log\n","key":"k0sctl-cache"}} + - {"name":"Kubectl cache","uses":"actions/cache@v3","with":{"path":"smoke-test/kubectl\n","key":"kubectl-1.21.3"}} + - {"name":"Go modules cache","uses":"actions/cache@v3","with":{"path":"~/go/pkg/mod\n~/.cache/go-build\n~/Library/Caches/go-build\n%LocalAppData%\\go-build\n","key":"${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}","restore-keys":"${{ runner.os }}-go-\n"}} + - {"name":"Docker Layer Caching For Bootloose","uses":"satackey/action-docker-layer-caching@v0.0.11","continue-on-error":true} + + - name: Run smoke tests + run: make smoke-files + + smoke-dynamic: + strategy: + matrix: + image: + - quay.io/k0sproject/bootloose-alpine3.18 + name: Basic dynamic config smoke + needs: build + runs-on: ubuntu-20.04 + + steps: + - uses: actions/checkout@v4 + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version-file: go.mod + check-latest: true + + - {"name":"Go modules cache","uses":"actions/cache@v3","with":{"path":"~/go/pkg/mod\n~/.cache/go-build\n~/Library/Caches/go-build\n%LocalAppData%\\go-build\n","key":"${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}","restore-keys":"${{ runner.os }}-go-\n"}} + - {"name":"Compiled binary cache","uses":"actions/download-artifact@v3","with":{"name":"k0sctl","path":"."}} + - {"name":"Make executable","run":"chmod +x k0sctl"} + - {"name":"K0sctl cache","uses":"actions/cache@v3","with":{"path":"/var/cache/k0sctl\n~/.cache/k0sctl\n!*.log\n","key":"k0sctl-cache"}} + - {"name":"Kubectl cache","uses":"actions/cache@v3","with":{"path":"smoke-test/kubectl\n","key":"kubectl-1.21.3"}} + - {"name":"Go modules cache","uses":"actions/cache@v3","with":{"path":"~/go/pkg/mod\n~/.cache/go-build\n~/Library/Caches/go-build\n%LocalAppData%\\go-build\n","key":"${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}","restore-keys":"${{ runner.os }}-go-\n"}} + - {"name":"Docker Layer Caching For Bootloose","uses":"satackey/action-docker-layer-caching@v0.0.11","continue-on-error":true} + + - name: Run smoke tests + run: make smoke-dynamic + + smoke-os-override: + name: OS override smoke test + needs: build + runs-on: ubuntu-20.04 + + steps: + - uses: actions/checkout@v4 + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version-file: go.mod + check-latest: true + + - {"name":"Go modules cache","uses":"actions/cache@v3","with":{"path":"~/go/pkg/mod\n~/.cache/go-build\n~/Library/Caches/go-build\n%LocalAppData%\\go-build\n","key":"${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}","restore-keys":"${{ runner.os }}-go-\n"}} + - {"name":"Compiled binary cache","uses":"actions/download-artifact@v3","with":{"name":"k0sctl","path":"."}} + - {"name":"Make executable","run":"chmod +x k0sctl"} + - {"name":"K0sctl cache","uses":"actions/cache@v3","with":{"path":"/var/cache/k0sctl\n~/.cache/k0sctl\n!*.log\n","key":"k0sctl-cache"}} + - {"name":"Kubectl cache","uses":"actions/cache@v3","with":{"path":"smoke-test/kubectl\n","key":"kubectl-1.21.3"}} + - {"name":"Go modules cache","uses":"actions/cache@v3","with":{"path":"~/go/pkg/mod\n~/.cache/go-build\n~/Library/Caches/go-build\n%LocalAppData%\\go-build\n","key":"${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}","restore-keys":"${{ runner.os }}-go-\n"}} + - {"name":"Docker Layer Caching For Bootloose","uses":"satackey/action-docker-layer-caching@v0.0.11","continue-on-error":true} + + - name: Run OS override smoke test + run: make smoke-os-override + + smoke-upgrade: + strategy: + matrix: + image: + - quay.io/k0sproject/bootloose-alpine3.18 + - quay.io/k0sproject/bootloose-amazonlinux2023 + - quay.io/k0sproject/bootloose-rockylinux9 + - quay.io/k0sproject/bootloose-ubuntu20.04 + k0s_from: + - v1.21.6+k0s.0 + name: Upgrade + needs: build + runs-on: ubuntu-20.04 + + steps: + - uses: actions/checkout@v4 + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version-file: go.mod + check-latest: true + + - {"name":"Go modules cache","uses":"actions/cache@v3","with":{"path":"~/go/pkg/mod\n~/.cache/go-build\n~/Library/Caches/go-build\n%LocalAppData%\\go-build\n","key":"${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}","restore-keys":"${{ runner.os }}-go-\n"}} + - {"name":"Compiled binary cache","uses":"actions/download-artifact@v3","with":{"name":"k0sctl","path":"."}} + - {"name":"Make executable","run":"chmod +x k0sctl"} + - {"name":"K0sctl cache","uses":"actions/cache@v3","with":{"path":"/var/cache/k0sctl\n~/.cache/k0sctl\n!*.log\n","key":"k0sctl-cache"}} + - {"name":"Kubectl cache","uses":"actions/cache@v3","with":{"path":"smoke-test/kubectl\n","key":"kubectl-1.21.3"}} + - {"name":"Go modules cache","uses":"actions/cache@v3","with":{"path":"~/go/pkg/mod\n~/.cache/go-build\n~/Library/Caches/go-build\n%LocalAppData%\\go-build\n","key":"${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}","restore-keys":"${{ runner.os }}-go-\n"}} + - {"name":"Docker Layer Caching For Bootloose","uses":"satackey/action-docker-layer-caching@v0.0.11","continue-on-error":true} + + - name: Run smoke tests + env: + LINUX_IMAGE: ${{ matrix.image }} + K0S_FROM: ${{ matrix.k0s_from }} + run: make smoke-upgrade + + smoke-reset: + strategy: + matrix: + image: + - quay.io/k0sproject/bootloose-rockylinux9 + - quay.io/k0sproject/bootloose-ubuntu20.04 + + name: Apply + reset + needs: build + runs-on: ubuntu-20.04 + + steps: + - uses: actions/checkout@v4 + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version-file: go.mod + check-latest: true + + - {"name":"Go modules cache","uses":"actions/cache@v3","with":{"path":"~/go/pkg/mod\n~/.cache/go-build\n~/Library/Caches/go-build\n%LocalAppData%\\go-build\n","key":"${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}","restore-keys":"${{ runner.os }}-go-\n"}} + - {"name":"Compiled binary cache","uses":"actions/download-artifact@v3","with":{"name":"k0sctl","path":"."}} + - {"name":"Make executable","run":"chmod +x k0sctl"} + - {"name":"K0sctl cache","uses":"actions/cache@v3","with":{"path":"/var/cache/k0sctl\n~/.cache/k0sctl\n!*.log\n","key":"k0sctl-cache"}} + - {"name":"Kubectl cache","uses":"actions/cache@v3","with":{"path":"smoke-test/kubectl\n","key":"kubectl-1.21.3"}} + - {"name":"Go modules cache","uses":"actions/cache@v3","with":{"path":"~/go/pkg/mod\n~/.cache/go-build\n~/Library/Caches/go-build\n%LocalAppData%\\go-build\n","key":"${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}","restore-keys":"${{ runner.os }}-go-\n"}} + - {"name":"Docker Layer Caching For Bootloose","uses":"satackey/action-docker-layer-caching@v0.0.11","continue-on-error":true} + + - name: Run smoke tests + env: + LINUX_IMAGE: ${{ matrix.image }} + run: make smoke-reset + + smoke-backup-restore: + strategy: + matrix: + image: + - quay.io/k0sproject/bootloose-alpine3.18 + - quay.io/k0sproject/bootloose-rockylinux9 + - quay.io/k0sproject/bootloose-ubuntu20.04 + + name: Apply + backup + reset + restore + needs: build + runs-on: ubuntu-20.04 + + steps: + - uses: actions/checkout@v4 + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version-file: go.mod + check-latest: true + + - {"name":"Go modules cache","uses":"actions/cache@v3","with":{"path":"~/go/pkg/mod\n~/.cache/go-build\n~/Library/Caches/go-build\n%LocalAppData%\\go-build\n","key":"${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}","restore-keys":"${{ runner.os }}-go-\n"}} + - {"name":"Compiled binary cache","uses":"actions/download-artifact@v3","with":{"name":"k0sctl","path":"."}} + - {"name":"Make executable","run":"chmod +x k0sctl"} + - {"name":"K0sctl cache","uses":"actions/cache@v3","with":{"path":"/var/cache/k0sctl\n~/.cache/k0sctl\n!*.log\n","key":"k0sctl-cache"}} + - {"name":"Kubectl cache","uses":"actions/cache@v3","with":{"path":"smoke-test/kubectl\n","key":"kubectl-1.21.3"}} + - {"name":"Go modules cache","uses":"actions/cache@v3","with":{"path":"~/go/pkg/mod\n~/.cache/go-build\n~/Library/Caches/go-build\n%LocalAppData%\\go-build\n","key":"${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}","restore-keys":"${{ runner.os }}-go-\n"}} + - {"name":"Docker Layer Caching For Bootloose","uses":"satackey/action-docker-layer-caching@v0.0.11","continue-on-error":true} + + - name: Run smoke tests + env: + LINUX_IMAGE: ${{ matrix.image }} + run: make smoke-backup-restore + + smoke-init: + name: Init sub-command smoke test + needs: build + runs-on: ubuntu-20.04 + + steps: + - uses: actions/checkout@v4 + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version-file: go.mod + check-latest: true + + - {"name":"Go modules cache","uses":"actions/cache@v3","with":{"path":"~/go/pkg/mod\n~/.cache/go-build\n~/Library/Caches/go-build\n%LocalAppData%\\go-build\n","key":"${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}","restore-keys":"${{ runner.os }}-go-\n"}} + - {"name":"Compiled binary cache","uses":"actions/download-artifact@v3","with":{"name":"k0sctl","path":"."}} + - {"name":"Make executable","run":"chmod +x k0sctl"} + - {"name":"K0sctl cache","uses":"actions/cache@v3","with":{"path":"/var/cache/k0sctl\n~/.cache/k0sctl\n!*.log\n","key":"k0sctl-cache"}} + - {"name":"Kubectl cache","uses":"actions/cache@v3","with":{"path":"smoke-test/kubectl\n","key":"kubectl-1.21.3"}} + - {"name":"Go modules cache","uses":"actions/cache@v3","with":{"path":"~/go/pkg/mod\n~/.cache/go-build\n~/Library/Caches/go-build\n%LocalAppData%\\go-build\n","key":"${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}","restore-keys":"${{ runner.os }}-go-\n"}} + - {"name":"Docker Layer Caching For Bootloose","uses":"satackey/action-docker-layer-caching@v0.0.11","continue-on-error":true} + + - name: Run init smoke test + run: make smoke-init + From 0148fa92724748188db0af5380f441a42348acb8 Mon Sep 17 00:00:00 2001 From: Kimmo Lehto Date: Thu, 12 Oct 2023 10:55:47 +0300 Subject: [PATCH 4/5] Update workflow paths Signed-off-by: Kimmo Lehto --- .github/workflows/actionlint.yml | 2 +- .github/workflows/go.yml | 2 ++ .github/workflows/smoke.yml | 6 ++++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/actionlint.yml b/.github/workflows/actionlint.yml index 6ca6cc5f..fa7888a3 100644 --- a/.github/workflows/actionlint.yml +++ b/.github/workflows/actionlint.yml @@ -2,7 +2,7 @@ name: Lint (actionlint) on: pull_request: paths: - - .github + - .github/** jobs: actionlint: diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 3542966d..8c70f2a0 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -4,6 +4,8 @@ on: pull_request: paths: - '**.go' + - go.mod + - go.sum jobs: gotest: diff --git a/.github/workflows/smoke.yml b/.github/workflows/smoke.yml index 308b05f2..d01cbc7b 100644 --- a/.github/workflows/smoke.yml +++ b/.github/workflows/smoke.yml @@ -4,9 +4,11 @@ on: pull_request: paths: - '**.go' + - go.mod + - go.sum - Makefile - - .github - - smoke-test + - .github/workflows/smoke.yml + - smoke-test/** jobs: From 1e0842d2ddec741cbacb67a0bd0982437c84a1cc Mon Sep 17 00:00:00 2001 From: Kimmo Lehto Date: Thu, 12 Oct 2023 11:15:18 +0300 Subject: [PATCH 5/5] Fix linting warnings on release workflow Signed-off-by: Kimmo Lehto --- .github/workflows/release.yaml | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index a3964d41..616052f4 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -12,13 +12,10 @@ jobs: steps: - name: Check out code into the Go module directory uses: actions/checkout@v4 - - # Ugly hack to get the tag name - # github.ref gives the full reference like refs.tags.v0.0.1-beta1 - - name: Branch name - id: branch_name - run: | - echo ::set-output name=TAG_NAME::${GITHUB_REF#refs/tags/} + + - name: Tag name + id: tag-name + run: echo "tag=${GITHUB_REF#refs/tags/}" >> "$GITHUB_OUTPUT" - name: Set up Go uses: actions/setup-go@v4 @@ -30,7 +27,7 @@ jobs: id: build_bins env: SEGMENT_WRITE_KEY: ${{ secrets.SEGMENT_WRITE_KEY }} - TAG_NAME: ${{ steps.branch_name.outputs.TAG_NAME }} + TAG_NAME: ${{ steps.tag-name.outputs.tag }} run: make build-all - name: Create release and upload binaries @@ -41,7 +38,7 @@ jobs: bin/k0sctl-* bin/checksums.txt body_path: bin/checksums.md - tag_name: ${{ steps.branch_name.outputs.TAG_NAME }} - name: ${{ steps.branch_name.outputs.TAG_NAME }} + tag_name: ${{ steps.tag-name.outputs.tag }} + name: ${{ steps.tag-name.outputs.tag }} draft: true # So we can manually edit before publishing - prerelease: ${{ contains(steps.branch_name.outputs.TAG_NAME, '-') }} # v0.1.2-beta1, 1.2.3-rc1 + prerelease: ${{ contains(steps.tag-name.outputs.tag, '-') }} # v0.1.2-beta1, 1.2.3-rc1