KFLUXINFRA-1064 adding checks for failed pull request workflow runs #30
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Validate PR - Testing Phase With SeaLights Monitoring - golang CI | |
on: | |
pull_request_target: | |
types: | |
- opened | |
- synchronize | |
- reopened | |
branches: | |
- main | |
repository_dispatch: | |
types: [trigger-mpc-test-with-sealights-ci] | |
concurrency: | |
group: ${{ github.event.pull_request.number }} | |
cancel-in-progress: true | |
jobs: | |
checkout_and_test: | |
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 }} | |
run: | | |
echo "Invalid context for this workflow run. Exiting." | |
exit 1 | |
- name: Check out code of the forked repository's head branch | |
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4 | |
with: | |
repository: ${{ github.event.pull_request.head.repo.full_name }} | |
ref: ${{ github.event.pull_request.head.ref }} | |
- 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: Initiating and configuring SeaLights | |
if: ${{ github.event_name == 'pull_request_target' && github.event.pull_request.head.sha && github.event.pull_request.number }} | |
run: | | |
echo "[Sealights] Initiating and configuring SeaLights to scan the pull request branch" | |
./slcli config init --lang go --token ./sltoken.txt | |
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: 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: Test | |
run: make test | |
- name: Codecov | |
uses: codecov/codecov-action@84508663e988701840491b86de86b666e8a86bed # v4 | |
- name: clean all SeaLights secret stuff | |
run: | | |
echo "[Sealights] Cleaning up after SeaLights run" | |
rm sltoken.txt buildSessionId.txt |