Skip to content

Commit f91876d

Browse files
authored
Run tests separately (#448)
1 parent 14f7f0d commit f91876d

File tree

290 files changed

+1321
-1001
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

290 files changed

+1321
-1001
lines changed

Diff for: .github/workflows/test.yml

+62-28
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,64 @@
1-
name: "Test"
1+
name: "Go Tests"
22

33
on:
44
push:
55
# Triggers the workflow on labeled PRs only.
66
pull_request_target:
77
types: [labeled]
88

9+
# Ensures that only the latest commit is running for each PR at a time.
10+
# Ignores this rule for push events.
11+
concurrency:
12+
group: ${{ github.event.pull_request.number || github.sha }}
13+
cancel-in-progress: true
914
jobs:
10-
tests:
15+
Pretest:
1116
if: contains(github.event.pull_request.labels.*.name, 'safe to test') || github.event_name == 'push'
12-
runs-on: ${{ matrix.os }}
13-
strategy:
14-
fail-fast: false
15-
matrix:
16-
os: [ubuntu-latest, windows-latest, macos-latest]
17+
runs-on: ubuntu-latest
1718
steps:
1819
- name: Unlabel 'safe to test'
1920
uses: actions-ecosystem/action-remove-labels@v1
20-
if: ${{github.event_name != 'push' }} && runner.os == 'Linux'
21+
if: ${{ github.event_name != 'push' }}
22+
with:
23+
labels: "safe to test"
24+
25+
- name: Checkout code
26+
uses: actions/checkout@v3
2127
with:
22-
labels: 'safe to test'
28+
ref: ${{ github.event.pull_request.head.sha }}
29+
30+
- name: Install Go
31+
uses: actions/setup-go@v3
32+
with:
33+
go-version: 1.20.x
34+
35+
- name: Go Cache
36+
uses: actions/cache@v3
37+
with:
38+
path: ~/go/pkg/mod
39+
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
40+
restore-keys: ${{ runner.os }}-go-
41+
42+
# Generate mocks
43+
- name: Generate mocks
44+
run: go generate ./...
45+
if: ${{ matrix.suite != 'unit' }}
46+
47+
- name: Lint
48+
run: go vet -v ./...
2349

50+
tests:
51+
needs: Pretest
52+
name: ${{ matrix.suite }} Tests (${{ matrix.os }})
53+
runs-on: ${{ matrix.os }}-latest
54+
env:
55+
JFROG_CLI_LOG_LEVEL: "DEBUG"
56+
strategy:
57+
fail-fast: false
58+
matrix:
59+
suite: [ unit, scanrepository, scanpullrequest, packagehandlers ]
60+
os: [ ubuntu, windows, macos ]
61+
steps:
2462
# Configure prerequisites
2563
- uses: actions/checkout@v3
2664
with:
@@ -29,10 +67,6 @@ jobs:
2967
uses: actions/setup-go@v3
3068
with:
3169
go-version: 1.20.x
32-
- name: Install npm
33-
uses: actions/setup-node@v3
34-
with:
35-
node-version: "16"
3670

3771
- name: Go Cache
3872
uses: actions/cache@v3
@@ -42,6 +76,11 @@ jobs:
4276
restore-keys: |
4377
${{ runner.os }}-go-
4478
79+
- name: Install npm
80+
uses: actions/setup-node@v3
81+
with:
82+
node-version: "16"
83+
4584
- name: Setup Python3
4685
uses: actions/setup-python@v4
4786
with:
@@ -53,26 +92,21 @@ jobs:
5392
# Generate mocks
5493
- name: Generate mocks
5594
run: go generate ./...
95+
if: ${{ matrix.suite != 'unit' }}
5696

57-
# Lint
58-
- name: Lint
59-
run: go vet ./...
60-
61-
# Run tests
62-
- name: Tests
63-
run: go test -p 1 ./... -v -race -timeout 30m -cover -coverprofile=covprofile -covermode=atomic
97+
- name: unit Tests
98+
run: go test github.com/jfrog/frogbot -v -race -timeout 30m -cover
6499
env:
65100
JF_URL: ${{ secrets.PLATFORM_URL }}
66101
JF_ACCESS_TOKEN: ${{ secrets.PLATFORM_ADMIN_TOKEN }}
67-
JFROG_CLI_LOG_LEVEL: "DEBUG"
68-
# Generate code coverage
69-
- name: Send coverage
70-
run: |
71-
go install github.com/mattn/goveralls@latest
72-
goveralls -coverprofile=covprofile -service=github
102+
if: ${{ matrix.suite == 'unit' }}
103+
104+
- name: ${{ matrix.test }} Tests
105+
run: go test github.com/jfrog/frogbot/${{ matrix.suite }} -v -race -timeout 30m -cover
73106
env:
74-
COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
75-
if: runner.os == 'Linux'
107+
JF_URL: ${{ secrets.PLATFORM_URL }}
108+
JF_ACCESS_TOKEN: ${{ secrets.PLATFORM_ADMIN_TOKEN }}
109+
if: ${{ matrix.suite != 'unit' }}
76110

77111
# Build and run frogbot current changes for visual sanity check.
78112
sanity-pull-request:

Diff for: action/node_modules/.package-lock.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)