diff --git a/.github/.wordlist.txt b/.github/.wordlist.txt deleted file mode 100644 index 1707423..0000000 --- a/.github/.wordlist.txt +++ /dev/null @@ -1,86 +0,0 @@ -AAAAAAAAAAAAAAAAAAAAAAAAAAAAA -abcde -acdlite -ADev -ALint -Amain -apiGroups -apiVersion -AProd -boyter -brightgreen -cdi -cli -cloner -ClusterRole -COCOMO -codebase -Codecov -datavolumes -dev -devs -dw -electrocucaracha -env -fieldPath -fieldRef -filesystems -formatter -gh -gha -ghcr -githubConfigSecret -githubConfigUrl -GraphQL -href -HTTPS -img -IShouldRefactorThis -isThereSeriouslyAnotherOne -js -json -JSX -kubectl -Kubernetes -KubeVirt -labelColor -laobi -lifecycle -linter -macOS -namespace -namespaces -npm -npmjs -oci -omgSoManyParameters -opensource -pre -precommit -PrettierCode -quickstart -RBAC -reallyLongArg -repo -runStrategy -scc -SCSS -ServiceAccount -serviceAccountName -sloc -src -svg -unpkg -valueFrom -virtiofs -VirtualMachine -VirtualMachineInstance -VirtualMachineInstances -VirtualMachines -vm -VMI -VMs -Vue -xyz -yaml -yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b7bd4fb..09ed335 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,120 +1,28 @@ -# SPDX-license-identifier: Apache-2.0 -############################################################################## -# Copyright (c) 2025 -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Apache License, Version 2.0 -# which accompanies this distribution, and is available at -# http://www.apache.org/licenses/LICENSE-2.0 -############################################################################## -name: Create and publish Docker image -# yamllint disable-line rule:truthy +name: Build + on: - workflow_dispatch: push: branches: - "master" tags: - "v*" - pull_request: - branches: - - "master" env: - REGISTRY: ghcr.io + REGISTRY: containers.openwow.dev IMAGE_NAME: ${{ github.repository }} jobs: - changes: - runs-on: ubuntu-latest - if: >- - ( github.event_name == 'pull_request_review' && github.event.review.state == 'approved' ) || github.event_name != 'pull_request_review' - outputs: - golang: ${{ steps.filter.outputs.golang }} - steps: - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # 4.2.2 - - uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # 3.0.2 - if: ${{ !env.ACT }} - id: filter - with: - token: ${{ secrets.GITHUB_TOKEN }} - filters: | - golang: - - '**.go' - code-coverage: - name: Check code coverage - if: needs.changes.outputs.golang == 'true' - needs: changes - runs-on: ubuntu-latest - permissions: - contents: write - issues: write - pull-requests: write - steps: - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # 4.2.2 - - uses: gwatts/go-coverage-action@2845595538a59d63d1bf55f109c14e104c6f7cb3 # 2.0.0 - with: - coverage-threshold: 40 - unit-test: - name: Check Go lang unit tests - if: needs.changes.outputs.golang == 'true' - needs: changes - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # 4.2.2 - - uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # 5.3.0 - with: - go-version: "^1.24" - - uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # 4.2.0 - if: ${{ !env.ACT }} - with: - path: | - ~/.cache/go-build - ~/go/pkg/mod - key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} - restore-keys: | - ${{ runner.os }}-go- - - uses: GoTestTools/gotestfmt-action@8b4478c7019be847373babde9300210e7de34bfb # 2.2.0 - - name: Run tests - run: | - set -euo pipefail - go test -json -v ./... 2>&1 | tee /tmp/gotest.log | gotestfmt - - name: Upload test log - uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # 4.6.0 - if: ${{ !env.ACT }} - with: - name: test-log - path: /tmp/gotest.log - if-no-files-found: error - push-registry: - name: Push Docker image to Docker Hub + build: + name: Build and publish Docker image runs-on: ubuntu-latest permissions: packages: write contents: read - attestations: write id-token: write - needs: [code-coverage, unit-test] steps: - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # 4.2.2 + - uses: actions/checkout@v4 - name: Log in to the Container registry - uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # 3.3.0 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - name: Extract metadata (tags, labels) for Docker - id: meta - uses: docker/metadata-action@369eb591f429131d6889c46b94e711f089e6ca96 # 5.6.1 - with: - images: ghcr.io/${{ github.repository }} - - name: Build and push Docker image - id: push - uses: docker/build-push-action@ca877d9245402d1537745e0e356eab47c3520991 # 6.13.0 - with: - push: ${{ github.event_name != 'pull_request' }} - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - - name: Generate artifact attestation - uses: actions/attest-build-provenance@520d128f165991a6c774bcb264f323e3d70747f4 # 2.2.0 - with: - subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}} - subject-digest: ${{ steps.push.outputs.digest }} - push-to-registry: true + run: | + echo ${{ secrets.GITHUB_TOKEN }} | docker login containers.openwow.dev -u ${{ github.actor }} --password-stdin + - name: Build Docker image + run: | + docker build . -t $REGISTRY/${{ github.repository }}:latest + docker push $REGISTRY/${{ github.repository }}:latest diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml deleted file mode 100644 index feef268..0000000 --- a/.github/workflows/linter.yml +++ /dev/null @@ -1,46 +0,0 @@ -# SPDX-license-identifier: Apache-2.0 -############################################################################## -# Copyright (c) 2024 -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Apache License, Version 2.0 -# which accompanies this distribution, and is available at -# http://www.apache.org/licenses/LICENSE-2.0 -############################################################################## -name: Lint Code Base -# yamllint disable-line rule:truthy -on: - push: - pull_request: -permissions: read-all -jobs: - get-sloc: - name: Count Lines of Code - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # 4.2.2 - - name: Setup Go - uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # 5.3.0 - with: - go-version: ">=1.20.0" - - name: Install dependencies - run: go install github.com/boyter/scc/v3@latest - - name: Run scc tool - run: scc --format wide - check-broken-links: - name: Check documentation external links - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # 4.2.2 - - name: Check broken links - uses: gaurav-nelson/github-action-markdown-link-check@636e17b35a5803e014b7272d9e46a8262705416a # 1.0.16 - check-super-linter: - name: Check syntax (super-linter) - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # 4.2.2 - - name: Run super-linter validation - uses: github/super-linter@b807e99ddd37e444d189cfd2c2ca1274d8ae8ef1 # 7 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - LINTER_RULES_PATH: / - VALIDATE_GO: false diff --git a/.github/workflows/spell.yml b/.github/workflows/spell.yml deleted file mode 100644 index 3a21837..0000000 --- a/.github/workflows/spell.yml +++ /dev/null @@ -1,35 +0,0 @@ -# SPDX-license-identifier: Apache-2.0 -############################################################################## -# Copyright (c) 2024 -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Apache License, Version 2.0 -# which accompanies this distribution, and is available at -# http://www.apache.org/licenses/LICENSE-2.0 -############################################################################## -name: Run misspell -# yamllint disable-line rule:truthy -on: - push: - paths: - - "**.md" - - "!.github/*" - pull_request_review: - types: - - submitted -permissions: read-all -jobs: - check-reviewdog: - name: Check spelling (reviewdog) - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # 4.2.2 - - uses: reviewdog/action-misspell@e2af6e5f797b1a26b3ccabfb316a3317c965a53d # 1.26.1 - with: - github_token: ${{ secrets.github_token }} - check-spellcheck: - name: Check spelling (pyspelling) - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # 4.2.2 - - uses: igsekor/pyspelling-any@155eb06641bb9259cab59b5126a40be943ecb4f7 # 1.0.4 - name: Spellcheck diff --git a/.github/workflows/update.yml b/.github/workflows/update.yml deleted file mode 100644 index ea01149..0000000 --- a/.github/workflows/update.yml +++ /dev/null @@ -1,46 +0,0 @@ -# SPDX-license-identifier: Apache-2.0 -############################################################################## -# Copyright (c) 2024 -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Apache License, Version 2.0 -# which accompanies this distribution, and is available at -# http://www.apache.org/licenses/LICENSE-2.0 -############################################################################## -name: Scheduled Versions verification -# yamllint disable-line rule:truthy -on: - schedule: - - cron: "0 0 * * 5" - workflow_dispatch: -permissions: read-all -jobs: - check-versions: - permissions: - contents: write # for technote-space/create-pr-action to push code - pull-requests: write # for technote-space/create-pr-action to create a PR - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # 4.2.2 - with: - # Fine-grained PAT with contents:write and workflows:write scopes - token: ${{ secrets.WORKFLOW_TOKEN }} - - uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # 5.3.0 - with: - go-version: "^1.24" - - uses: technote-space/create-pr-action@91114507cf92349bec0a9a501c2edf1635427bc5 # 2.1.4 - with: - EXECUTE_COMMANDS: | - ./ci/update_versions.sh - COMMIT_MESSAGE: "Upgrade versions files" - COMMIT_NAME: "electrocucaracha bot" - PR_BRANCH_NAME: "versions-update-${PR_ID}" - PR_TITLE: "chore: update versions" - check-dockerfile: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # 4.2.2 - - name: update Dockerfile - uses: ludeeus/dockerfile-updater@eaf8ea79220d076eb46c127fa9895e3de3e0a512 # 21.01.0 - with: - token: ${{ secrets.GITHUB_TOKEN }} - pr_title: "chore: update Dockerfile" diff --git a/internal/runner.go b/internal/runner.go index 62f3ec2..75978ce 100644 --- a/internal/runner.go +++ b/internal/runner.go @@ -192,37 +192,39 @@ func (rc *KubevirtRunner) WaitForVirtualMachineInstance(ctx context.Context, vir const reportingElapse = 5.0 - watch, err := rc.virtClient.VirtualMachineInstance(rc.namespace).Watch(ctx, k8smetav1.ListOptions{}) - if err != nil { - return errors.Wrap(err, "failed to watch the virtual machine instance") - } - defer watch.Stop() + for rc.currentStatus != v1.Succeeded && rc.currentStatus != v1.Failed { + watch, err := rc.virtClient.VirtualMachineInstance(rc.namespace).Watch(ctx, k8smetav1.ListOptions{}) + if err != nil { + return errors.Wrap(err, "failed to watch the virtual machine instance") + } + defer watch.Stop() - lastTimeChecked := time.Now() + lastTimeChecked := time.Now() - for event := range watch.ResultChan() { - vmi, ok := event.Object.(*v1.VirtualMachineInstance) - if ok && vmi.Name == rc.virtualMachineInstance { - if vmi.Status.Phase != rc.currentStatus { - rc.currentStatus = vmi.Status.Phase - lastTimeChecked = time.Now() + for event := range watch.ResultChan() { + vmi, ok := event.Object.(*v1.VirtualMachineInstance) + if ok && vmi.Name == rc.virtualMachineInstance { + if vmi.Status.Phase != rc.currentStatus { + rc.currentStatus = vmi.Status.Phase + lastTimeChecked = time.Now() - switch rc.currentStatus { - case v1.Succeeded: - log.Printf("%s has successfully completed\n", virtualMachineInstance) + switch rc.currentStatus { + case v1.Succeeded: + log.Printf("%s has successfully completed\n", virtualMachineInstance) - return nil - case v1.Failed: - log.Printf("%s has failed\n", virtualMachineInstance) + return nil + case v1.Failed: + log.Printf("%s has failed\n", virtualMachineInstance) - return ErrRunnerFailed - default: - log.Printf("%s has transitioned to %s phase \n", virtualMachineInstance, rc.currentStatus) - } - } else if time.Since(lastTimeChecked).Minutes() > reportingElapse { - log.Printf("%s is in %s phase \n", virtualMachineInstance, rc.currentStatus) + return ErrRunnerFailed + default: + log.Printf("%s has transitioned to %s phase \n", virtualMachineInstance, rc.currentStatus) + } + } else if time.Since(lastTimeChecked).Minutes() > reportingElapse { + log.Printf("%s is in %s phase \n", virtualMachineInstance, rc.currentStatus) - lastTimeChecked = time.Now() + lastTimeChecked = time.Now() + } } } }