Skip to content

Commit

Permalink
Merge branch 'master' into feat/refresh-context
Browse files Browse the repository at this point in the history
  • Loading branch information
Antonito committed Jun 22, 2022
2 parents d55e443 + 88859d2 commit a8cd890
Show file tree
Hide file tree
Showing 34 changed files with 864 additions and 244 deletions.
1 change: 1 addition & 0 deletions .github/hooks/pre-commit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@
exec 1>&2

.github/lint-disallowed-functions-in-library.sh
.github/lint-no-trailing-newline-in-log-messages.sh
41 changes: 41 additions & 0 deletions .github/lint-no-trailing-newline-in-log-messages.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/env bash

#
# DO NOT EDIT THIS FILE
#
# It is automatically copied from https://github.com/pion/.goassets repository.
#
# If you want to update the shared CI config, send a PR to
# https://github.com/pion/.goassets instead of this repository.
#

set -e

# Disallow usages of functions that cause the program to exit in the library code
SCRIPT_PATH=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )
if [ -f ${SCRIPT_PATH}/.ci.conf ]
then
. ${SCRIPT_PATH}/.ci.conf
fi

files=$(
find "$SCRIPT_PATH/.." -name "*.go" \
| while read file
do
excluded=false
for ex in $EXCLUDE_DIRECTORIES
do
if [[ $file == */$ex/* ]]
then
excluded=true
break
fi
done
$excluded || echo "$file"
done
)

if grep -E '\.(Trace|Debug|Info|Warn|Error)f?\("[^"]*\\n"\)?' $files | grep -v -e 'nolint'; then
echo "Log format strings should have trailing new-line"
exit 1
fi
40 changes: 40 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: "CodeQL"

on:
workflow_dispatch:
schedule:
- cron: '23 5 * * 0'
pull_request:
branches:
- master
paths:
- '**.go'

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

steps:
- name: Checkout repo
uses: actions/checkout@v3

# The code in examples/ might intentionally do things like log credentials
# in order to show how the library is used, aid in debugging etc. We
# should ignore those for CodeQL scanning, and only focus on the package
# itself.
- name: Remove example code
run: |
rm -rf examples/
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: 'go'

- name: CodeQL Analysis
uses: github/codeql-action/analyze@v2
4 changes: 4 additions & 0 deletions .github/workflows/generate-authors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ on:

jobs:
checksecret:
permissions:
contents: none
runs-on: ubuntu-latest
outputs:
is_PIONBOT_PRIVATE_KEY_set: ${{ steps.checksecret_job.outputs.is_PIONBOT_PRIVATE_KEY_set }}
Expand All @@ -28,6 +30,8 @@ jobs:
echo "::set-output name=is_PIONBOT_PRIVATE_KEY_set::${{ env.PIONBOT_PRIVATE_KEY != '' }}"
generate-authors:
permissions:
contents: write
needs: [checksecret]
if: needs.checksecret.outputs.is_PIONBOT_PRIVATE_KEY_set == 'true'
runs-on: ubuntu-latest
Expand Down
12 changes: 11 additions & 1 deletion .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ on:
- opened
- edited
- synchronize

permissions:
contents: read

jobs:
lint-commit-message:
name: Metadata
Expand All @@ -36,8 +40,14 @@ jobs:
- name: Functions
run: .github/lint-disallowed-functions-in-library.sh

- name: Logging messages should not have trailing newlines
run: .github/lint-no-trailing-newline-in-log-messages.sh

lint-go:
name: Go
permissions:
contents: read
pull-requests: read
runs-on: ubuntu-latest
strategy:
fail-fast: false
Expand All @@ -47,5 +57,5 @@ jobs:
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.31
version: v1.45.2
args: $GOLANGCI_LINT_EXRA_ARGS
3 changes: 3 additions & 0 deletions .github/workflows/renovate-go-mod-fix.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ on:
branches:
- renovate/*

permissions:
contents: write

jobs:
go-mod-fix:
runs-on: ubuntu-latest
Expand Down
37 changes: 26 additions & 11 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,22 @@ on:
pull_request:
branches:
- master

permissions:
contents: read

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
go: ["1.16", "1.17"]
go: ["1.17", "1.18"]
fail-fast: false
name: Go ${{ matrix.go }}
steps:
- uses: actions/checkout@v3

- uses: actions/cache@v2
- uses: actions/cache@v3
with:
path: |
~/go/pkg/mod
Expand All @@ -44,18 +48,31 @@ jobs:
go-version: ${{ matrix.go }}

- name: Setup go-acc
run: |
go get github.com/ory/go-acc
git checkout go.mod go.sum
run: go install github.com/ory/go-acc@latest

- name: Set up gotestfmt
uses: haveyoudebuggedit/gotestfmt-action@v2
with:
token: ${{ secrets.GITHUB_TOKEN }} # Avoid getting rate limited

- name: Run test
run: |
TEST_BENCH_OPTION="-bench=."
if [ -f .github/.ci.conf ]; then . .github/.ci.conf; fi
set -euo pipefail
go-acc -o cover.out ./... -- \
${TEST_BENCH_OPTION} \
-v -race
-json \
-v -race 2>&1 | grep -v '^go: downloading' | tee /tmp/gotest.log | gotestfmt
- name: Upload test log
uses: actions/upload-artifact@v2
if: always()
with:
name: test-log-${{ matrix.go }}
path: /tmp/gotest.log
if-no-files-found: error

- name: Run TEST_HOOK
run: |
Expand All @@ -64,7 +81,6 @@ jobs:
- uses: codecov/codecov-action@v2
with:
file: ./cover.out
name: codecov-umbrella
fail_ci_if_error: true
flags: go
Expand All @@ -73,13 +89,13 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
go: ["1.16", "1.17"]
go: ["1.17", "1.18"]
fail-fast: false
name: Go i386 ${{ matrix.go }}
steps:
- uses: actions/checkout@v3

- uses: actions/cache@v2
- uses: actions/cache@v3
with:
path: |
~/go/pkg/mod
Expand Down Expand Up @@ -117,7 +133,7 @@ jobs:
with:
node-version: '16.x'

- uses: actions/cache@v2
- uses: actions/cache@v3
with:
path: |
~/go/pkg/mod
Expand Down Expand Up @@ -153,7 +169,6 @@ jobs:
- uses: codecov/codecov-action@v2
with:
file: ./cover.out
name: codecov-umbrella
fail_ci_if_error: true
flags: wasm
3 changes: 3 additions & 0 deletions .github/workflows/tidy-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ on:
branches:
- master

permissions:
contents: read

jobs:
Check:
runs-on: ubuntu-latest
Expand Down
34 changes: 32 additions & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,22 @@ linters-settings:
linters:
enable:
- asciicheck # Simple linter to check that your code does not contain non-ASCII identifiers
- bidichk # Checks for dangerous unicode character sequences
- bodyclose # checks whether HTTP response body is closed successfully
- contextcheck # check the function whether use a non-inherited context
- deadcode # Finds unused code
- decorder # check declaration order and count of types, constants, variables and functions
- depguard # Go linter that checks if package imports are in a list of acceptable packages
- dogsled # Checks assignments with too many blank identifiers (e.g. x, _, _, _, := f())
- dupl # Tool for code clone detection
- durationcheck # check for two durations multiplied together
- errcheck # Errcheck is a program for checking for unchecked errors in go programs. These unchecked errors can be critical bugs in some cases
- errchkjson # Checks types passed to the json encoding functions. Reports unsupported types and optionally reports occations, where the check for the returned error can be omitted.
- errname # Checks that sentinel errors are prefixed with the `Err` and error types are suffixed with the `Error`.
- errorlint # errorlint is a linter for that can be used to find code that will cause problems with the error wrapping scheme introduced in Go 1.13.
- exhaustive # check exhaustiveness of enum switch statements
- exportloopref # checks for pointers to enclosing loop variables
- forcetypeassert # finds forced type assertions
- gci # Gci control golang package import order and make it always deterministic.
- gochecknoglobals # Checks that no globals are present in Go code
- gochecknoinits # Checks that no init functions are present in Go code
Expand All @@ -35,40 +43,62 @@ linters:
- gofumpt # Gofumpt checks whether code was gofumpt-ed.
- goheader # Checks is file header matches to pattern
- goimports # Goimports does everything that gofmt does. Additionally it checks unused imports
- golint # Golint differs from gofmt. Gofmt reformats Go source code, whereas golint prints out style mistakes
- gomoddirectives # Manage the use of 'replace', 'retract', and 'excludes' directives in go.mod.
- gomodguard # Allow and block list linter for direct Go module dependencies. This is different from depguard where there are different block types for example version constraints and module recommendations.
- goprintffuncname # Checks that printf-like functions are named with `f` at the end
- gosec # Inspects source code for security problems
- gosimple # Linter for Go source code that specializes in simplifying a code
- govet # Vet examines Go source code and reports suspicious constructs, such as Printf calls whose arguments do not align with the format string
- grouper # An analyzer to analyze expression groups.
- importas # Enforces consistent import aliases
- ineffassign # Detects when assignments to existing variables are not used
- misspell # Finds commonly misspelled English words in comments
- nakedret # Finds naked returns in functions greater than a specified function length
- nilerr # Finds the code that returns nil even if it checks that the error is not nil.
- nilnil # Checks that there is no simultaneous return of `nil` error and an invalid value.
- noctx # noctx finds sending http request without context.Context
- scopelint # Scopelint checks for unpinned variables in go programs
- predeclared # find code that shadows one of Go's predeclared identifiers
- revive # golint replacement, finds style mistakes
- staticcheck # Staticcheck is a go vet on steroids, applying a ton of static analysis checks
- structcheck # Finds unused struct fields
- stylecheck # Stylecheck is a replacement for golint
- tagliatelle # Checks the struct tags.
- tenv # tenv is analyzer that detects using os.Setenv instead of t.Setenv since Go1.17
- tparallel # tparallel detects inappropriate usage of t.Parallel() method in your Go test codes
- typecheck # Like the front-end of a Go compiler, parses and type-checks Go code
- unconvert # Remove unnecessary type conversions
- unparam # Reports unused function parameters
- unused # Checks Go code for unused constants, variables, functions and types
- varcheck # Finds unused global variables and constants
- wastedassign # wastedassign finds wasted assignment statements
- whitespace # Tool for detection of leading and trailing whitespace
disable:
- containedctx # containedctx is a linter that detects struct contained context.Context field
- cyclop # checks function and package cyclomatic complexity
- exhaustivestruct # Checks if all struct's fields are initialized
- forbidigo # Forbids identifiers
- funlen # Tool for detection of long functions
- gocyclo # Computes and checks the cyclomatic complexity of functions
- godot # Check if comments end in a period
- gomnd # An analyzer to detect magic numbers.
- ifshort # Checks that your code uses short syntax for if-statements whenever possible
- ireturn # Accept Interfaces, Return Concrete Types
- lll # Reports long lines
- maintidx # maintidx measures the maintainability index of each function.
- makezero # Finds slice declarations with non-zero initial length
- maligned # Tool to detect Go structs that would take less memory if their fields were sorted
- nestif # Reports deeply nested if statements
- nlreturn # nlreturn checks for a new line before return and branch statements to increase code clarity
- nolintlint # Reports ill-formed or insufficient nolint directives
- paralleltest # paralleltest detects missing usage of t.Parallel() method in your Go test
- prealloc # Finds slice declarations that could potentially be preallocated
- promlinter # Check Prometheus metrics naming via promlint
- rowserrcheck # checks whether Err of rows is checked successfully
- sqlclosecheck # Checks that sql.Rows and sql.Stmt are closed.
- testpackage # linter that makes you use a separate _test package
- thelper # thelper detects golang test helpers without t.Helper() call and checks the consistency of test helpers
- varnamelen # checks that the length of a variable's name matches its scope
- wrapcheck # Checks that errors returned from external packages are wrapped
- wsl # Whitespace Linter - Forces you to use empty lines!

issues:
Expand Down
2 changes: 2 additions & 0 deletions AUTHORS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
# This file is auto generated, using git to list all individuals contributors.
# see `.github/generate-authors.sh` for the scripting
adamroach <[email protected]>
Adrian Cable <[email protected]>
Agniva De Sarker <[email protected]>
Antoine Baché <[email protected]>
Antoine Baché <[email protected]>
Atsushi Watanabe <[email protected]>
backkem <[email protected]>
chenkaiC4 <[email protected]>
Expand Down
Loading

0 comments on commit a8cd890

Please sign in to comment.