Skip to content

Get rid of local dependency cache #34

Get rid of local dependency cache

Get rid of local dependency cache #34

name: Validate PR - Testing Phase With SeaLights Monitoring - golang CI
on:
pull_request_target:
types:
- opened
- synchronize
- reopened
branches: [ main ]
push:
branches: [ main ]
repository_dispatch:
types: [trigger-mpc-test-with-sealights-ci]
concurrency:
group: ${{ github.workflow }}-${{ (github.event_name == 'pull_request_target' && github.event.pull_request.number) || github.ref }}
cancel-in-progress: true
jobs:
checkout_and_test:
name: Golang Unit tests
runs-on: ubuntu-latest
steps:
- name: Determine workflow run event context
run: echo "on-event=${{ github.event_name }}" >> $GITHUB_ENV
- name: Handle invalid context for pull requests
if: ${{ env.on-event == 'pull_request_target' && (!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 pull request head code - on pull_request event
if: env.on-event == 'pull_request_target'
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:
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 the SeaLights agent
run: |
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_target'
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"
./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