Skip to content

Commit

Permalink
Merge branch 'main' into fix/close-invoke-race
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickhuie19 authored Dec 8, 2023
2 parents 82f7fce + 432f5e0 commit 0ee5352
Show file tree
Hide file tree
Showing 33 changed files with 1,416 additions and 422 deletions.
107 changes: 105 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,73 @@
name: wsrpc
on: push

on:
push:

jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version-file: 'go.mod'

##
# XXX: change this to the official action once multiple --out-format args are supported.
# See: https://github.com/golangci/golangci-lint-action/issues/612
##
- name: golangci-lint
uses: smartcontractkit/golangci-lint-action@54ab6c5f11d66a92d14c3f7cc41ea13f676644bd # feature/multiple-output-formats-backup
with:
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
version: v1.52.1

# Optional: working directory, useful for monorepos
# working-directory:

# Optional: golangci-lint command line arguments.
allow-extra-out-format-args: true
args: --timeout=2m0s --out-format checkstyle:golangci-lint-report.xml

# Optional: show only new issues if it's a pull request. The default value is `false`.
only-new-issues: true

# Optional: if set to true then the action will use pre-installed Go.
# skip-go-installation: true

# Optional: if set to true then the action don't cache or restore ~/go/pkg.
# skip-pkg-cache: true

# Optional: if set to true then the action don't cache or restore ~/.cache/go-build.
# skip-build-cache: true

- name: Print lint report artifact
if: always()
run: test -f golangci-lint-report.xml && cat golangci-lint-report.xml || true

- name: Upload lint report artifact
if: always()
uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # v3.1.0
with:
name: golangci-lint-report
path: golangci-lint-report.xml

ci_test:
name: CI Tests
runs-on: ubuntu-latest
steps:
- name: Checkout the repo
uses: actions/checkout@v2

- name: Setup Go
uses: actions/setup-go@v3
with:
go-version-file: "go.mod"
cache: true

- name: Cache dependencies
uses: actions/cache@v2
with:
Expand All @@ -21,5 +77,52 @@ jobs:
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go
- name: Run Test Suite
run: go test -p=1 -race ./...
run: set -o pipefail && go test ./... -coverpkg=./... -coverprofile=coverage.txt $1 | tee $OUTPUT_FILE

- name: Run Race Test Suite
run: set -o pipefail && go test -race ./... -coverpkg=./... -coverprofile=race_coverage.txt $1 | tee $OUTPUT_FILE

- name: Upload Go test results
if: always()
uses: actions/upload-artifact@v3
with:
name: go-test-results
path: |
./output.txt
./coverage.txt
./race_coverage.txt
sonar-scan:
name: SonarQube
needs: [lint, ci_test]
runs-on: ubuntu-latest
if: always()
steps:
- name: Checkout the repo
uses: actions/checkout@v3
with:
fetch-depth: 0 # fetches all history for all tags and branches to provide more metadata for sonar reports

- name: Download all workflow run artifacts
uses: actions/download-artifact@9782bd6a9848b53b110e712e20e42d89988822b7 # v3.0.1

- name: Set SonarQube Report Paths
id: sonarqube_report_paths
shell: bash
run: |
echo "sonarqube_tests_report_paths=$(find -type f -name 'output.txt' -printf "%p,")" >> $GITHUB_OUTPUT
echo "sonarqube_coverage_report_paths=$(find -type f -name '*coverage.txt' -printf "%p,")" >> $GITHUB_OUTPUT
echo "sonarqube_golangci_report_paths=$(find -type f -name 'golangci-lint-report.xml' -printf "%p,")" >> $GITHUB_OUTPUT
- name: SonarQube Scan
uses: sonarsource/sonarqube-scan-action@a6ba0aafc293e03de5437af7edbc97f7d3ebc91a # v1.2.0
with:
args: >
-Dsonar.go.tests.reportPaths=${{ steps.sonarqube_report_paths.outputs.sonarqube_tests_report_paths }}
-Dsonar.go.coverage.reportPaths=${{ steps.sonarqube_report_paths.outputs.sonarqube_coverage_report_paths }}
-Dsonar.go.golangci-lint.reportPaths=${{ steps.sonarqube_report_paths.outputs.sonarqube_golangci_report_paths }}
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
52 changes: 52 additions & 0 deletions .github/workflows/dependency-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Dependency Vulnerability Check

on:
push:

jobs:
changes:
name: Detect changes
runs-on: ubuntu-latest
outputs:
changes: ${{ steps.changes.outputs.src }}
steps:
- name: Checkout the repo
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
- uses: dorny/paths-filter@4512585405083f25c027a35db413c2b3b9006d50 # v2.11.1
id: changes
with:
filters: |
src:
- '**/*go.sum'
- '**/*go.mod'
- '.github/workflows/dependency-check.yml'
Go:
runs-on: ubuntu-latest
needs: [changes]
steps:
- name: Check out code
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version-file: 'go.mod'
id: go

- name: Write Go Modules list
run: go list -json -m all > go.list

- name: Check vulnerabilities
uses: sonatype-nexus-community/nancy-github-action@main
with:
nancyVersion: "v1.0.42"

- name: Collect Metrics
if: always()
id: collect-gha-metrics
uses: smartcontractkit/push-gha-metrics-action@90fcbaac8ebf86da9c4d55dba24f6fe3029f0e0b
with:
basic-auth: ${{ secrets.GRAFANA_CLOUD_BASIC_AUTH }}
hostname: ${{ secrets.GRAFANA_CLOUD_HOST }}
this-job-name: Go
continue-on-error: true
37 changes: 0 additions & 37 deletions .github/workflows/lint.yml

This file was deleted.

5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,8 @@

# Editors
.vscode

# Test & linter reports
*report.xml
*report.json
*.out
Loading

0 comments on commit 0ee5352

Please sign in to comment.