Skip to content

Update git action #1746

Update git action

Update git action #1746

Workflow file for this run

name: "Go Tests"
on:
push:
# Triggers the workflow on labeled PRs only.
pull_request_target:
types: [ labeled ]
jobs:
tests:
if: contains(github.event.pull_request.labels.*.name, 'safe to test') || github.event_name == 'push'
runs-on: ${{ matrix.os }}-latest
name: ${{ matrix.suite }} (${{ matrix.os }})
strategy:
fail-fast: false
matrix:
suite: [ Scan-Pull-Request, Scan-All-Pull-Requests, Scan-Repository, Scan-Multiple-Repositories, Package-Handlers, Resolve-Dependency ]
os: [ ubuntu, windows, macos ]
steps:
- name: Unlabel 'safe to test'
uses: actions-ecosystem/action-remove-labels@v1
if: ${{github.event_name != 'push' }} && runner.os == 'Linux' && ${{ matrix.suite == 'Scan-Pull-Request' }}
with:
labels: 'safe to test'
# Configure prerequisites
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: 1.20.x
- name: Install npm
uses: actions/setup-node@v3
with:
node-version: "16"
- name: Go Cache
uses: actions/cache@v3
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Setup Python3
uses: actions/setup-python@v4
with:
python-version: "3.x"
- name: Install python components
run: python -m pip install pipenv poetry
# Generate mocks
- name: Generate mocks
run: go generate ./...
# Lint
- name: Lint
run: go vet ./...
# Run tests
- name: Tests
run: go test -race -timeout 30m -cover -v -test.${{ matrix.suite }}
env:
JF_URL: ${{ secrets.PLATFORM_URL }}
JF_ACCESS_TOKEN: ${{ secrets.PLATFORM_ADMIN_TOKEN }}
JFROG_CLI_LOG_LEVEL: "DEBUG"
# Build and run frogbot current changes for visual sanity check.
sanity-pull-request:
needs: tests
if: ${{ github.event_name != 'push' }}
runs-on: ubuntu-latest
steps:
- name: Install Go
uses: actions/setup-go@v3
with:
go-version: 1.20.x
- name: Checkout code
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Build Frogbot
run: buildscripts/build.sh
- name: Scan
env:
JF_URL: ${{ secrets.FROGBOT_URL }}
JF_ACCESS_TOKEN: ${{ secrets.FROGBOT_ACCESS_TOKEN }}
JF_GIT_TOKEN: ${{ secrets.GITHUB_TOKEN }}
JF_GIT_PULL_REQUEST_ID: ${{ github.event.number }}
JF_GIT_PROVIDER: "github"
JF_GIT_OWNER: ${{ github.repository_owner }}
JF_GIT_REPO: ${{ github.event.repository.name }}
run: ./frogbot scan-pull-request