Skip to content

Commit

Permalink
Ci improvements (#820)
Browse files Browse the repository at this point in the history
* re organize some workflows, update go version
* add command on Makefile to execute coverage test
* remove useless env var on coverage test
* remove submodules option
  • Loading branch information
emmanuelm41 committed Oct 1, 2021
1 parent 6590940 commit c28d33a
Show file tree
Hide file tree
Showing 8 changed files with 80 additions and 74 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/generate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Checkout
uses: actions/checkout@v2
- uses: actions/cache@v2
id: generate-dep-cache
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/label-syncer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
branches:
- master
jobs:
build:
sync_labels:
name: Sync labels
runs-on: ubuntu-latest
steps:
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Checkout
uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: '^1.17'
- uses: actions/cache@v2
id: lint-dep-cache
with:
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v2
with:
submodules: true
- uses: actions/setup-go@v2
with:
go-version: '^1.16'
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/publish_tagged.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v2
with:
submodules: true
- uses: actions/setup-go@v2
with:
go-version: '^1.16'
Expand Down
105 changes: 60 additions & 45 deletions .github/workflows/regression.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,49 +9,64 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/cache@v2
id: cache
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Fetch Dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: go get ./...
- name: Dir Setup
run: mkdir -p ~/go/bin
- name: Build
run: go build . && cp drand ~/go/bin/drand-candidate

- uses: actions/checkout@v2
with:
ref: 'master'
- name: Fetch Dependencies
run: go get ./...
- name: Build
run: go build . && cp drand ~/go/bin/drand-existing

- uses: actions/checkout@v2
- id: regression
name: Run regression
run: go run ./demo/regression -release ~/go/bin/drand-existing -candidate ~/go/bin/drand-candidate

- id: report
if: ${{ failure() }}
name: Save report
run: |
OUTPUT=$(cat report.md)
OUTPUT="${OUTPUT//'%'/'%25'}"
OUTPUT="${OUTPUT//$'\n'/'%0A'}"
OUTPUT="${OUTPUT//$'\r'/'%0D'}"
echo "::set-output name=result::$OUTPUT"
- name: Record Comment
if: ${{ failure() }}
uses: marocchino/sticky-pull-request-comment@v1
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
message: ${{ steps.report.outputs.result }}
# Deps
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: '^1.17'
- name: Dir Setup
run: mkdir -p ~/go/bin

# Master branch
- name: Checkout master branch
uses: actions/checkout@v2
with:
ref: 'master'
- name: Check cache for master
uses: actions/cache@v2
id: cache_master
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Build Master
run: make build . && cp drand ~/go/bin/drand-existing

# Candidate branch
- name: Checkout candidate branch
uses: actions/checkout@v2
- name: Check cache for candidate
uses: actions/cache@v2
id: cache_candidate
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Build Candidate
run: make build && cp drand ~/go/bin/drand-candidate

# Regression test
- name: Run regression
id: regression
run: go run ./demo/regression -release ~/go/bin/drand-existing -candidate ~/go/bin/drand-candidate

# Report
- id: report
if: ${{ failure() }}
name: Save report
run: |
OUTPUT=$(cat report.md)
OUTPUT="${OUTPUT//'%'/'%25'}"
OUTPUT="${OUTPUT//$'\n'/'%0A'}"
OUTPUT="${OUTPUT//$'\r'/'%0D'}"
echo "::set-output name=result::$OUTPUT"
- name: Record Comment
if: ${{ failure() }}
uses: marocchino/sticky-pull-request-comment@v1
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
message: ${{ steps.report.outputs.result }}

21 changes: 8 additions & 13 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,10 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v2
with:
submodules: true
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: '^1.16'
go-version: '^1.17'
- uses: actions/cache@v2
id: cache
with:
Expand All @@ -36,11 +34,9 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v2
with:
submodules: true
- uses: actions/setup-go@v2
with:
go-version: '^1.16'
go-version: '^1.17'
- uses: actions/cache@v2
id: cache
with:
Expand All @@ -51,26 +47,25 @@ jobs:
- run: go get -v -t -d ./...
- name: Unit tests
run: make test-unit
- run: make test-integration
- name: Integration tests
run: make test-integration

coverage:
runs-on: ubuntu-latest
env:
CI: "true"
steps:
- name: Checkout
uses: actions/checkout@v2
with:
submodules: true
- uses: actions/setup-go@v2
with:
go-version: '^1.16'
go-version: '^1.17'
- uses: actions/cache@v2
id: cache
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- run: go get -u github.com/ory/go-acc
- run: go get -v -t -d ./...
- run: go-acc ./...
- run: make coverage
- run: bash <(curl -s https://codecov.io/bash)
13 changes: 4 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,10 @@ test-integration:
go test -v ./demo
cd demo && go build && ./demo -build -test -debug

linter:
@echo "Checking (& upgrading) formatting of files. (if this fail, re-run until success)"
@{ \
files=$$( go fmt ./... ); \
if [ -n "$$files" ]; then \
echo "Files not properly formatted: $$files"; \
exit 1; \
fi; \
}
coverage:
go get -u github.com/ory/go-acc
go get -v -t -d ./...
COVERAGE=true go-acc ./...

demo:
cd demo && go build && ./demo -build
Expand Down

0 comments on commit c28d33a

Please sign in to comment.