Skip to content

Commit

Permalink
Migrate lint, coverage, and unit-test jobs from CircleCi to GitHub Ac…
Browse files Browse the repository at this point in the history
…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
nitaliya and jeffreyc-splunk authored Nov 18, 2021
1 parent a477fab commit 38c12ba
Show file tree
Hide file tree
Showing 2 changed files with 141 additions and 50 deletions.
50 changes: 0 additions & 50 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,6 @@ workflows:
build-and-test:
jobs:
- setup-environment
- lint:
requires:
- setup-environment
- cross-compile:
requires:
- setup-environment
Expand All @@ -111,12 +108,6 @@ workflows:
- docker-otelcol-windows:
requires:
- cross-compile
- test:
requires:
- setup-environment
- coverage:
requires:
- setup-environment
- build-package:
name: deb-package
package_type: deb
Expand Down Expand Up @@ -170,14 +161,6 @@ jobs:
root: ~/
paths: go/bin

lint:
executor: golang
steps:
- attach_to_workspace
- run:
name: Lint
command: make -j4 checklicense impi lint misspell

cross-compile:
executor: golang
parallelism: 4
Expand All @@ -192,39 +175,6 @@ jobs:
- store_artifacts:
path: bin

test:
executor: golang
environment:
TEST_RESULTS: unit-test-results/junit/results.xml
steps:
- attach_to_workspace
- run:
name: Unit tests
command: |
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
- store_artifacts:
path: unit-test-results
- store_test_results:
path: unit-test-results/junit
- save_module_cache

coverage:
executor: golang
steps:
- attach_to_workspace
- run:
name: Install packages.
command: sudo apt update && sudo apt-get install bzr time
- run:
name: Coverage tests
command: make test-with-cover
# DISABLE CODECOV UNTIL THE SCRIPT IS AUDITED AND WE ARE CERTAIN IT IS OK TO TO EXECUTE IT.
# - run:
# name: Code coverage
# command: bash <(curl -s https://codecov.io/bash)

docker-otelcol:
parameters:
os:
Expand Down
141 changes: 141 additions & 0 deletions .github/workflows/build-and-test.yml
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)

0 comments on commit 38c12ba

Please sign in to comment.