Skip to content

Commit f444505

Browse files
authored
chore(circleci): split unit/integration tests (#700)
| Q | A | ----------------- | ---------- | Bug fix? | no | New feature? | no | BC breaks? | no | Related Issue | - | Need Doc update | no ## Describe your change This PR split the unit tests and the integration tests in CircleCI into dedicated jobs: `unit-tests` & `integration-tests`. ## What problem is this fixing? The `integrations-tests` require credentials, and those credentials are **NOT** forwarded to fork pull requests. It means that **ALL** pull requests made by any external contributor is failing from the CI point of view. The idea is to disable the integrations tests suite on fork pull request because anyway they won't pass (see [CircleCI documentation](https://circleci.com/blog/triggering-trusted-ci-jobs-on-untrusted-forks/)). ## Next steps We have to change the required checks from `test-1.XX` to ` unit-tests-1.XX`. The integration tests become optional but since they cannot run on every PRs anyway it makes no sense to have them required. If they are failing it's our responsibility to check the output.
1 parent 29468c2 commit f444505

File tree

1 file changed

+50
-7
lines changed

1 file changed

+50
-7
lines changed

.circleci/config.yml

Lines changed: 50 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ commands:
1111
curl -s https://algoliasearch-client-keygen.herokuapp.com | sh >> $BASH_ENV
1212
fi
1313
14-
test:
15-
description: "Run the test for Go << parameters.go_version >>"
14+
unit-tests:
15+
description: "Run the unit tests for Go << parameters.go_version >>"
1616
parameters:
1717
go_version:
1818
type: string
@@ -23,8 +23,18 @@ commands:
2323
- run:
2424
name: Run unit tests for Go << parameters.go_version >>
2525
command: make unit-tests
26+
27+
integration-tests:
28+
description: "Run the integration tests for Go << parameters.go_version >>"
29+
parameters:
30+
go_version:
31+
type: string
32+
steps:
2633
- run:
27-
name: Run tests for Go << parameters.go_version >>
34+
name: Generate code for Go << parameters.go_version >>
35+
command: go generate ./...
36+
- run:
37+
name: Run integration tests for Go << parameters.go_version >>
2838
command: |
2939
if [ -z "ALGOLIA_ADMIN_KEY_MCM" ]; then
3040
make integration-tests-community
@@ -47,7 +57,24 @@ jobs:
4757
name: Check formatting
4858
command: make lint
4959

50-
test:
60+
unit-tests:
61+
parameters:
62+
go_version:
63+
type: string
64+
docker:
65+
- image: cimg/go:<< parameters.go_version >>
66+
steps:
67+
- checkout
68+
- restore_cache:
69+
key: go-cache-<< parameters.go_version >>
70+
- unit-tests:
71+
go_version: "<< parameters.go_version >>"
72+
- save_cache:
73+
key: go-cache-<< parameters.go_version >>
74+
paths:
75+
- "~/go/pkg"
76+
77+
integration-tests:
5178
parameters:
5279
go_version:
5380
type: string
@@ -58,18 +85,34 @@ jobs:
5885
- restore_cache:
5986
key: go-cache-<< parameters.go_version >>
6087
- credentials
61-
- test:
88+
- integration-tests:
6289
go_version: "<< parameters.go_version >>"
6390
- save_cache:
6491
key: go-cache-<< parameters.go_version >>
6592
paths:
6693
- "~/go/pkg"
6794

6895
workflows:
69-
build:
96+
ci:
7097
jobs:
7198
- format
72-
- test:
99+
100+
- unit-tests:
101+
matrix:
102+
parameters:
103+
go_version:
104+
- "1.13"
105+
- "1.14"
106+
- "1.15"
107+
- "1.16"
108+
- "1.17"
109+
110+
- integration-tests:
111+
filters:
112+
branches:
113+
# Forked pull requests have CIRCLE_BRANCH set to pull/XXX
114+
# https://circleci.com/blog/triggering-trusted-ci-jobs-on-untrusted-forks/
115+
ignore: /pull\/[0-9]+/
73116
matrix:
74117
parameters:
75118
go_version:

0 commit comments

Comments
 (0)