forked from open-telemetry/opentelemetry-collector
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate lint, coverage, and unit-test jobs from CircleCi to GitHub Ac…
…tion. (open-telemetry#937) * Migrate lint, coverage, and unit-test jobs. * Making suggested changes. * Making suggested changes. Co-authored-by: Jeff Cheng <83052155+jcheng-splunk@users.noreply.github.com> * Adding coverage.html in artifacts. Co-authored-by: Jeff Cheng <83052155+jcheng-splunk@users.noreply.github.com>
- Loading branch information
1 parent
a477fab
commit 38c12ba
Showing
2 changed files
with
141 additions
and
50 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
name: build-and-test | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
|
||
concurrency: | ||
group: build-and-test-${{ github.event.pull_request.number || github.ref }} | ||
cancel-in-progress: true | ||
|
||
env: | ||
PYTHON_VERSION: 3.8.5 | ||
PIP_VERSION: 20.2.4 | ||
REQUIREMENTS_PATH: "internal/buildscripts/packaging/tests/requirements.txt" | ||
RESULT_PATH: "~/testresults" | ||
GO_VERSION: 1.17.2 | ||
|
||
jobs: | ||
setup-environment: | ||
name: setup-environment | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out the codebase. | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: ${{ env.GO_VERSION }} | ||
|
||
- name: Caching dependency | ||
uses: actions/cache@v2 | ||
with: | ||
path: | | ||
~/.cache/go-build | ||
~/go/pkg/mod | ||
~/go/bin | ||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | ||
|
||
- name: Installing dependency | ||
run: | | ||
make install-tools | ||
lint: | ||
name: lint | ||
runs-on: ubuntu-latest | ||
needs: [setup-environment] | ||
steps: | ||
- name: Check out the codebase. | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: ${{ env.GO_VERSION }} | ||
|
||
- name: Caching dependency | ||
uses: actions/cache@v2 | ||
with: | ||
path: | | ||
~/.cache/go-build | ||
~/go/pkg/mod | ||
~/go/bin | ||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | ||
|
||
- name: Lint | ||
run: | | ||
make -j4 checklicense impi lint misspell | ||
test: | ||
name: test | ||
runs-on: ubuntu-latest | ||
needs: [setup-environment] | ||
steps: | ||
- name: Check out the codebase. | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: ${{ env.GO_VERSION }} | ||
|
||
- name: Caching dependency | ||
uses: actions/cache@v2 | ||
with: | ||
path: | | ||
~/.cache/go-build | ||
~/go/pkg/mod | ||
~/go/bin | ||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | ||
|
||
- name: Unit tests | ||
run: | | ||
mkdir -p unit-test-results/junit | ||
trap "go-junit-report -set-exit-code < unit-test-results/go-unit-tests.out > unit-test-results/junit/results.xml" EXIT | ||
make test | tee unit-test-results/go-unit-tests.out | ||
- name: Uploading artifacts | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: unit-test-results | ||
path: ./unit-test-results | ||
|
||
coverage: | ||
name: coverage | ||
runs-on: ubuntu-latest | ||
needs: [setup-environment] | ||
steps: | ||
- name: Check out the codebase. | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: ${{ env.GO_VERSION }} | ||
|
||
- name: Caching dependency | ||
uses: actions/cache@v2 | ||
with: | ||
path: | | ||
~/.cache/go-build | ||
~/go/pkg/mod | ||
~/go/bin | ||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | ||
|
||
- name: Coverage tests | ||
run: | | ||
make test-with-cover | ||
- name: Uploading artifacts | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: coverage-results | ||
path: ./coverage.html | ||
|
||
# DISABLE CODECOV UNTIL THE SCRIPT IS AUDITED AND WE ARE CERTAIN IT IS OK TO TO EXECUTE IT. | ||
# - name: Code coverage | ||
# run: | | ||
# bash <(curl -s https://codecov.io/bash) |