diff --git a/.github/workflows/codecov-main.yaml b/.github/workflows/codecov-main.yaml deleted file mode 100644 index 2ab61a46..00000000 --- a/.github/workflows/codecov-main.yaml +++ /dev/null @@ -1,19 +0,0 @@ -name: Codecov report on push to the "main" branch -on: - push: - branches: [ main ] -jobs: - coverage: - name: Unit tests and coverage report - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4 - - uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5 - with: - go-version-file: './go.mod' - - name: Build - run: make build - - name: Run tests - run: make test - - name: Codecov - uses: codecov/codecov-action@84508663e988701840491b86de86b666e8a86bed # v4 \ No newline at end of file diff --git a/.github/workflows/sealights-mpc-test-ci.yaml b/.github/workflows/mpc-test-sealights.yaml similarity index 64% rename from .github/workflows/sealights-mpc-test-ci.yaml rename to .github/workflows/mpc-test-sealights.yaml index 605318d6..1a009b87 100644 --- a/.github/workflows/sealights-mpc-test-ci.yaml +++ b/.github/workflows/mpc-test-sealights.yaml @@ -6,14 +6,16 @@ on: - opened - synchronize - reopened - branches: - - main + branches: [ main ] + + push: + branches: [ main ] repository_dispatch: types: [trigger-mpc-test-with-sealights-ci] concurrency: - group: ${{ github.event.pull_request.number }} + group: ${{ github.workflow }}-${{ (github.event_name == 'pull_request_target' && github.event.pull_request.number) || github.ref }} cancel-in-progress: true jobs: @@ -21,16 +23,29 @@ jobs: name: Golang Unit tests runs-on: ubuntu-latest steps: - - name: Handle invalid context - if: ${{ !github.event.pull_request.head.sha || !github.event.pull_request.number }} + - name: Determine workflow run event context + run: | + if [ "${{ github.event_name }}" == "push" ]; then + echo "Running tests on the merged main branch" + echo "on-event=push" >> $GITHUB_ENV + else + echo "Running tests on the pull request head branch" + echo "on-event=pull_request" >> $GITHUB_ENV + fi + - name: Handle invalid context for pull requests + if: ${{ env.on-event == 'pull_request' && (!github.event.pull_request.head.sha || !github.event.pull_request.number) }} run: | echo "Invalid context for this workflow run. Exiting." exit 1 - - name: Check out code of the forked repository's head branch + - name: Check out pull request head code - on pull_request event + if: ${{env.on-event}} == "pull_request" uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4 with: repository: ${{ github.event.pull_request.head.repo.full_name }} ref: ${{ github.event.pull_request.head.ref }} + - name: Check out main code - on push event + if: ${{env.on-event}} == "push" + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4 - name: Install Go uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5 with: @@ -51,17 +66,25 @@ jobs: run: echo "${SEALIGHTS_AGENT_TOKEN}" > sltoken.txt env: SEALIGHTS_AGENT_TOKEN: '${{secrets.SEALIGHTS_AGENT_TOKEN}}' - - name: Initiating and configuring SeaLights - if: ${{ github.event_name == 'pull_request_target' && github.event.pull_request.head.sha && github.event.pull_request.number }} + - name: Initiating the SeaLights agent run: | - echo "[Sealights] Initiating and configuring SeaLights to scan the pull request branch" + echo "[Sealights] Initiating the SeaLights agent to Goland and handing it the token" ./slcli config init --lang go --token ./sltoken.txt + - name: Configuring SeaLights - on pull_request event + if: ${{env.on-event}} == "pull_request" + run: | + echo "[Sealights] Configuring SeaLights to scan the pull request branch" echo "Latest commit sha: ${LATEST_COMMIT_SHA}" echo "PR Number: ${PULL_REQUEST_NUMBER}" ./slcli config create-pr-bsid --app multi-platform-controller --target-branch "main" --pull-request-number ${PULL_REQUEST_NUMBER} --latest-commit ${LATEST_COMMIT_SHA} --repository-url https://github.com/konflux-ci/multi-platform-controller env: PULL_REQUEST_NUMBER: ${{ github.event.pull_request.number || github.event.issue.number }} LATEST_COMMIT_SHA: ${{github.event.pull_request.head.sha}} + - name: Configuring SeaLights - on push event + if: ${{env.on-event}} == "push" + run: | + echo "[Sealights] Configuring SeaLights to scan the main branch after pull request was closed" + ./slcli config create-bsid --app multi-platform-controller --branch main --build multi-platform-controller-main-$(date +'%Y.%m.%d_%H:%M') - name: Run the SeaLights scan run: | echo "[Sealights] Running the SeaLights scan" diff --git a/.github/workflows/sealights-mpc-scan-on-merged-main.yaml b/.github/workflows/sealights-mpc-scan-on-merged-main.yaml deleted file mode 100644 index 3cc2505e..00000000 --- a/.github/workflows/sealights-mpc-scan-on-merged-main.yaml +++ /dev/null @@ -1,57 +0,0 @@ -name: Run A SeaLights Scan Main Branch After A Pull Request Has Been Merged - -on: - workflow_run: - workflows: - - Trigger on PR Merge - types: - - completed - -jobs: - run-after-merge: - if: github.repository == 'konflux-ci/multi-platform-controller' - runs-on: ubuntu-latest - steps: - - name: Checkout Main Repository - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4 - with: - ref: main - - name: Install Go - uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5 - with: - go-version-file: "./go.mod" - - name: Download SeaLights Go agent and CLI tool - run: | - echo "[Sealights] Downloading Sealights Golang & CLI Agents..." - case $(lscpu | awk '/Architecture:/{print $2}') in - x86_64) SL_ARCH="linux-amd64";; - arm) SL_ARCH="linux-arm64";; - esac - wget -nv -O sealights-go-agent.tar.gz https://agents.sealights.co/slgoagent/latest/slgoagent-$SL_ARCH.tar.gz - wget -nv -O sealights-slcli.tar.gz https://agents.sealights.co/slcli/latest/slcli-$SL_ARCH.tar.gz - tar -xzf ./sealights-go-agent.tar.gz && tar -xzf ./sealights-slcli.tar.gz - rm -f ./sealights-go-agent.tar.gz ./sealights-slcli.tar.gz - ./slgoagent -v 2> /dev/null | grep version && ./slcli -v 2> /dev/null | grep version - - name: Write SeaLights token into file - run: echo "${SEALIGHTS_AGENT_TOKEN}" > sltoken.txt - env: - SEALIGHTS_AGENT_TOKEN: '${{secrets.SEALIGHTS_AGENT_TOKEN}}' - - name: Create component of build name for SeaLights config command - run: echo "date=$(date +'%y%m%d.%H:%M')" >> $GITHUB_ENV - - name: Initiating and configuring SeaLights - run: | - echo "[Sealights] Initiating and configuring SeaLights to scan the main branch after pull request was closed" - ./slcli config init --lang go --token ./sltoken.txt - ./slcli config create-bsid --app multi-platform-controller --branch main --build ${BUILD_NAME} - env: - BUILD_NAME: multi-platform-controller-main-${{env.date}} - - name: Run the SeaLights scan - run: | - echo "[Sealights] Running the SeaLights scan" - ./slcli scan --bsid buildSessionId.txt --path-to-scanner ./slgoagent --workspacepath ./ --scm git --scmBaseUrl https://github.com/konflux-ci/multi-platform-controller --scmVersion “0” --scmProvider github - - name: Build - run: make build - - name: clean all SeaLights secret stuff - run: | - echo "[Sealights] Cleaning up after SeaLights run" - rm sltoken.txt buildSessionId.txt diff --git a/.github/workflows/trigger-sealights-mpc-scan-on-merged-main.yaml b/.github/workflows/trigger-sealights-mpc-scan-on-merged-main.yaml deleted file mode 100644 index e406b05e..00000000 --- a/.github/workflows/trigger-sealights-mpc-scan-on-merged-main.yaml +++ /dev/null @@ -1,14 +0,0 @@ -name: Trigger on PR Merge - -on: - pull_request: - types: - - closed - -jobs: - pr-merge: - if: github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'main' - runs-on: ubuntu-latest - steps: - - name: Notify Merge Complete - run: echo "Pull request merged into main. Triggering SeaLights scan on merged main workflow." \ No newline at end of file