chore: simplify a bit QA workflow #16939
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: QA | |
on: | |
push: | |
branches: [master] | |
pull_request: | |
branches: [master] | |
types: [assigned, opened, synchronize, reopened, edited, ready_for_review] | |
jobs: | |
filter: | |
runs-on: ubuntu-latest | |
if: github.event.pull_request.draft == false | |
outputs: | |
backend: ${{ steps.filter.outputs.go }} | |
frontend: ${{ steps.filter.outputs.ui }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: dorny/paths-filter@v3 | |
id: filter | |
with: | |
filters: | | |
frontend: | |
- 'ui/**' | |
backend: | |
- 'api/**' | |
- 'agent/**' | |
- 'pkg/**' | |
- 'ssh/**' | |
- 'cli/**' | |
- 'tests/**' | |
backend: | |
needs: filter | |
if: needs.filter.outputs.backend == 'true' | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
service: [api, agent, pkg, ssh, cli, tests] | |
include: | |
- service: agent | |
extra_args: "-tags docker" | |
lint_args: "--build-tags docker" | |
- service: ssh | |
extra_args: "-tags internal_api" | |
lint_args: "--build-tags internal_api" | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: "1.21" | |
- name: Cache Go dependencies | |
uses: actions/cache@v3 | |
with: | |
path: ~/go/pkg/mod | |
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | |
- name: Install & verify dependencies | |
working-directory: ${{ matrix.service }} | |
run: | | |
go mod download | |
../devscripts/prepare-release | |
if [ -n "$(git status --porcelain)" ]; then | |
echo "Missing dependencies in 'go.mod'" | |
exit 1 | |
fi | |
- name: Check formatting | |
run: | | |
if [ "$(gofmt -s -l . | wc -l)" -gt 0 ]; then | |
echo "Code formatting issues found" | |
exit 1 | |
fi | |
- name: Lint code | |
uses: golangci/golangci-lint-action@v6 | |
with: | |
working-directory: ${{ matrix.service }} | |
version: v1.63.2 | |
args: --timeout 2m ${{ matrix.lint_args || '' }} ./... | |
skip-cache: true | |
- name: Build | |
if: matrix.service != 'tests' | |
working-directory: ${{ matrix.service }} | |
run: go build -v ${{ matrix.extra_args || '' }} ./... | |
- name: Run tests | |
working-directory: ${{ matrix.service }} | |
run: go test -v ${{ matrix.extra_args || '' }} -timeout 25m -parallel 4 ./... | |
env: | |
TESTCONTAINERS_RYUK_DISABLED: true | |
frontend: | |
needs: filter | |
if: needs.filter.outputs.frontend == 'true' | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: "21.4.0" | |
- name: Cache Node modules | |
uses: actions/cache@v3 | |
with: | |
path: ui/node_modules | |
key: ${{ runner.OS }}-ui-${{ hashFiles('**/package-lock.json') }} | |
- name: Install dependencies | |
working-directory: ui | |
run: npm install | |
- name: Run tests | |
working-directory: ui | |
run: npm run test | |
- name: Run linting | |
working-directory: ui | |
run: npm run lint |