From 5292d6b8fbb9568ccc8749c31f03c81d0f5d8645 Mon Sep 17 00:00:00 2001 From: Noel Georgi Date: Tue, 23 Apr 2024 23:31:44 +0530 Subject: [PATCH] chore(ci): kresify gh actions Kresify, only handle gh workflows. Signed-off-by: Noel Georgi --- .github/workflows/ci.yaml | 193 ++++++++++++++++++++++++++++ .github/workflows/slack-notify.yaml | 92 +++++++++++++ .kres.yaml | 94 ++++++++++++++ Makefile | 5 + hack/test/e2e-docker.sh | 2 +- hack/test/e2e-iso.sh | 2 +- hack/test/e2e.sh | 2 +- 7 files changed, 387 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/ci.yaml create mode 100644 .github/workflows/slack-notify.yaml create mode 100644 .kres.yaml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 00000000000..a954ed30a9b --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,193 @@ +# THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT. +# +# Generated on 2024-04-27T13:51:36Z by kres ebc009d-dirty. + +name: default +concurrency: + group: ${{ github.head_ref || github.run_id }} + cancel-in-progress: true +"on": + push: + branches: + - main + - release-* + tags: + - v* + pull_request: + branches: + - main + - release-* +jobs: + default: + permissions: + actions: read + contents: write + issues: read + packages: write + pull-requests: read + runs-on: + - self-hosted + - generic + if: (!startsWith(github.head_ref, 'renovate/') && !startsWith(github.head_ref, 'dependabot/')) + services: + buildkitd: + image: moby/buildkit:v0.13.1 + options: --privileged + ports: + - 1234:1234 + volumes: + - /var/lib/buildkit/${{ github.repository }}:/var/lib/buildkit + - /usr/etc/buildkit/buildkitd.toml:/etc/buildkit/buildkitd.toml + steps: + - name: checkout + uses: actions/checkout@v4 + - name: Unshallow + run: | + git fetch --prune --unshallow + - name: Set up Docker Buildx + id: setup-buildx + uses: docker/setup-buildx-action@v3 + with: + driver: remote + endpoint: tcp://127.0.0.1:1234 + timeout-minutes: 10 + - name: external-artifacts + run: | + make external-artifacts + - name: generate + run: | + make generate docs + - name: uki-certs + run: | + make uki-certs PLATFORM=linux/amd64 + - name: check-dirty + run: | + make check-dirty + - name: build + run: | + make talosctl-all kernel sd-boot sd-stub initramfs installer imager talos _out/integration-test-linux-amd64 PLATFORM=linux/amd64,linux/arm64 IMAGE_REGISTRY=registry.dev.siderolabs.io PUSH=true + - name: lint + run: | + make lint + - name: talosctl-cni-bundle + run: | + make talosctl-cni-bundle + - name: iso + run: | + make iso secureboot-iso IMAGE_REGISTRY=registry.dev.siderolabs.io + - name: images-essential + run: | + make images-essential IMAGE_REGISTRY=registry.dev.siderolabs.io + - name: unit-tests + run: | + make unit-tests + - name: unit-tests-race + run: | + make unit-tests-race + - name: coverage + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + make coverage + continue-on-error: true + timeout-minutes: 1 + - name: Generate executable list + run: | + find _out -type f -executable > _out/executable-artifacts + - name: save-artifacts + uses: actions/upload-artifact@v4 + with: + name: artifacts + path: | + _out + retention-days: "5" + e2e-docker-short: + permissions: + actions: read + contents: write + issues: read + packages: write + pull-requests: read + runs-on: + - self-hosted + - generic + if: (!startsWith(github.head_ref, 'renovate/') && !startsWith(github.head_ref, 'dependabot/')) + needs: + - default + steps: + - name: checkout + uses: actions/checkout@v4 + - name: Unshallow + run: | + git fetch --prune --unshallow + - name: Download artifacts + uses: actions/download-artifact@v4 + with: + name: artifacts + path: _out + - name: Fix artifact permissions + run: | + xargs -a _out/executable-artifacts -I {} chmod +x {} + - name: e2e-docker + run: | + make e2e-docker IMAGE_REGISTRY=registry.dev.siderolabs.io SHORT_INTEGRATION_TEST=yes + e2e-iso: + permissions: + actions: read + contents: write + issues: read + packages: write + pull-requests: read + runs-on: + - self-hosted + - generic + if: (!startsWith(github.head_ref, 'renovate/') && !startsWith(github.head_ref, 'dependabot/')) + needs: + - default + steps: + - name: checkout + uses: actions/checkout@v4 + - name: Unshallow + run: | + git fetch --prune --unshallow + - name: Download artifacts + uses: actions/download-artifact@v4 + with: + name: artifacts + path: _out + - name: Fix artifact permissions + run: | + xargs -a _out/executable-artifacts -I {} chmod +x {} + - name: e2e-iso + run: | + sudo -E make e2e-iso IMAGE_REGISTRY=registry.dev.siderolabs.io + e2e-qemu-short: + permissions: + actions: read + contents: write + issues: read + packages: write + pull-requests: read + runs-on: + - self-hosted + - talos + if: (!startsWith(github.head_ref, 'renovate/') && !startsWith(github.head_ref, 'dependabot/')) + needs: + - default + steps: + - name: checkout + uses: actions/checkout@v4 + - name: Unshallow + run: | + git fetch --prune --unshallow + - name: Download artifacts + uses: actions/download-artifact@v4 + with: + name: artifacts + path: _out + - name: Fix artifact permissions + run: | + xargs -a _out/executable-artifacts -I {} chmod +x {} + - name: e2e-qemu + run: | + sudo -E make e2e-qemu IMAGE_REGISTRY=registry.dev.siderolabs.io SHORT_INTEGRATION_TEST=yes diff --git a/.github/workflows/slack-notify.yaml b/.github/workflows/slack-notify.yaml new file mode 100644 index 00000000000..f92a0812a51 --- /dev/null +++ b/.github/workflows/slack-notify.yaml @@ -0,0 +1,92 @@ +# THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT. +# +# Generated on 2024-04-27T09:00:21Z by kres ebc009d-dirty. + +name: slack-notify +"on": + workflow_run: + workflows: + - default + types: + - completed +jobs: + slack-notify: + runs-on: + - self-hosted + - generic + if: github.event.workflow_run.conclusion != 'skipped' + steps: + - name: Get PR number + id: get-pr-number + if: github.event.workflow_run.event == 'pull_request' + env: + GH_TOKEN: ${{ github.token }} + run: | + echo pull_request_number=$(gh pr view -R ${{ github.repository }} ${{ github.event.workflow_run.head_repository.owner.login }}:${{ github.event.workflow_run.head_branch }} --json number --jq .number) >> $GITHUB_OUTPUT + - name: Slack Notify + uses: slackapi/slack-github-action@v1 + with: + channel-id: proj-talos-maintainers + payload: | + { + "attachments": [ + { + "color": "${{ github.event.workflow_run.conclusion == 'success' && '#2EB886' || github.event.workflow_run.conclusion == 'failure' && '#A30002' || '#FFCC00' }}", + "fallback": "test", + "blocks": [ + { + "type": "section", + "fields": [ + { + "type": "mrkdwn", + "text": "${{ github.event.workflow_run.event == 'pull_request' && format('*Pull Request:* {0} (`{1}`)\n<{2}/pull/{3}|{4}>', github.repository, github.ref_name, github.event.repository.html_url, steps.get-pr-number.outputs.pull_request_number, github.event.workflow_run.display_title) || format('*Build:* {0} (`{1}`)\n<{2}/commit/{3}|{4}>', github.repository, github.ref_name, github.event.repository.html_url, github.sha, github.event.workflow_run.display_title) }}" + }, + { + "type": "mrkdwn", + "text": "*Status:*\n`${{ github.event.workflow_run.conclusion }}`" + } + ] + }, + { + "type": "section", + "fields": [ + { + "type": "mrkdwn", + "text": "*Author:*\n`${{ github.actor }}`" + }, + { + "type": "mrkdwn", + "text": "*Event:*\n`${{ github.event.workflow_run.event }}`" + } + ] + }, + { + "type": "divider" + }, + { + "type": "actions", + "elements": [ + { + "type": "button", + "text": { + "type": "plain_text", + "text": "Logs" + }, + "url": "${{ github.event.workflow_run.html_url }}" + }, + { + "type": "button", + "text": { + "type": "plain_text", + "text": "Commit" + }, + "url": "${{ github.event.repository.html_url }}/commit/${{ github.sha }}" + } + ] + } + ] + } + ] + } + env: + SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} diff --git a/.kres.yaml b/.kres.yaml new file mode 100644 index 00000000000..57f2b1a38b6 --- /dev/null +++ b/.kres.yaml @@ -0,0 +1,94 @@ +--- +kind: auto.CI +spec: + compileGHWorkflowsOnly: true +--- +kind: common.GHWorkflow +spec: + jobs: + - name: default + setupBuildx: true + runners: + - self-hosted + - generic + steps: + - name: external-artifacts + - name: generate + command: generate docs + - name: uki-certs + arguments: + - PLATFORM=linux/amd64 + - name: check-dirty + - name: build + command: talosctl-all kernel sd-boot sd-stub initramfs installer imager talos _out/integration-test-linux-amd64 + arguments: + - PLATFORM=linux/amd64,linux/arm64 + - IMAGE_REGISTRY=registry.dev.siderolabs.io + - PUSH=true + - name: lint + - name: talosctl-cni-bundle + - name: iso + command: iso secureboot-iso + arguments: + - IMAGE_REGISTRY=registry.dev.siderolabs.io + - name: images-essential + arguments: + - IMAGE_REGISTRY=registry.dev.siderolabs.io + - name: unit-tests + - name: unit-tests-race + - name: coverage + environment: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + timeoutMinutes: 1 + continueOnError: true + - name: save-artifacts + artifactStep: + type: upload + artifactPath: _out + - name: e2e-iso + depends: + - default + runners: + - self-hosted + - generic + steps: + - name: download-artifacts + artifactStep: + type: download + artifactPath: _out + - name: e2e-iso + withSudo: true + arguments: + - IMAGE_REGISTRY=registry.dev.siderolabs.io + - name: e2e-qemu-short + depends: + - default + runners: + - self-hosted + - talos + steps: + - name: download-artifacts + artifactStep: + type: download + artifactPath: _out + - name: e2e-qemu + withSudo: true + arguments: + - IMAGE_REGISTRY=registry.dev.siderolabs.io + - SHORT_INTEGRATION_TEST=yes + - name: e2e-docker-short + depends: + - default + runners: + - self-hosted + - generic + steps: + - name: download-artifacts + artifactStep: + type: download + artifactPath: _out + - name: e2e-docker + withSudo: false + arguments: + - IMAGE_REGISTRY=registry.dev.siderolabs.io + - SHORT_INTEGRATION_TEST=yes diff --git a/Makefile b/Makefile index 1bbe2988124..9eb71e85356 100644 --- a/Makefile +++ b/Makefile @@ -448,6 +448,11 @@ unit-tests: ## Performs unit tests. unit-tests-race: ## Performs unit tests with race detection enabled. @$(MAKE) target-$@ TARGET_ARGS="--allow security.insecure" PLATFORM=linux/amd64 + +.PHONY: coverage +coverage: ## Upload coverage data to codecov.io. + bash -c "bash <(curl -s https://codecov.io/bash) -f $(ARTIFACTS)/coverage.txt -X fix" + $(ARTIFACTS)/$(INTEGRATION_TEST_DEFAULT_TARGET)-amd64: @$(MAKE) local-$(INTEGRATION_TEST_DEFAULT_TARGET) DEST=$(ARTIFACTS) PLATFORM=linux/amd64 WITH_RACE=true NAME=Client PUSH=false diff --git a/hack/test/e2e-docker.sh b/hack/test/e2e-docker.sh index 9c8972928e2..0810198a924 100755 --- a/hack/test/e2e-docker.sh +++ b/hack/test/e2e-docker.sh @@ -21,7 +21,7 @@ function create_cluster { --memory=2048 \ --cpus=2.0 \ --with-init-node=false \ - ${REGISTRY_MIRROR_FLAGS} \ + "${REGISTRY_MIRROR_FLAGS[@]}" \ --crashdump "${TALOSCTL}" config node 10.5.0.2 diff --git a/hack/test/e2e-iso.sh b/hack/test/e2e-iso.sh index dd702308ddb..25df7786112 100755 --- a/hack/test/e2e-iso.sh +++ b/hack/test/e2e-iso.sh @@ -27,7 +27,7 @@ function create_cluster { --install-image=${REGISTRY:-ghcr.io}/siderolabs/installer:${TAG} \ --cni-bundle-url=${ARTIFACTS}/talosctl-cni-bundle-'${ARCH}'.tar.gz \ --crashdump \ - ${REGISTRY_MIRROR_FLAGS} + "${REGISTRY_MIRROR_FLAGS[@]}" "${TALOSCTL}" config node "${NODE}" } diff --git a/hack/test/e2e.sh b/hack/test/e2e.sh index 10f180ad162..63a92132b25 100755 --- a/hack/test/e2e.sh +++ b/hack/test/e2e.sh @@ -210,7 +210,7 @@ function build_registry_mirrors { if [[ "${CI:-false}" == "true" ]]; then REGISTRY_MIRROR_FLAGS=() - for registry in docker.io registry.k8s.io quay.io gcr.io ghcr.io registry.dev.talos-systems.io; do + for registry in docker.io registry.k8s.io quay.io gcr.io ghcr.io; do local service="registry-${registry//./-}.ci.svc" addr=$(python3 -c "import socket; print(socket.gethostbyname('${service}'))")