Skip to content

Commit

Permalink
[#36]: chore: tests with Go workspaces
Browse files Browse the repository at this point in the history
  • Loading branch information
rustatian authored Sep 27, 2023
2 parents b6cadf6 + 9339f18 commit c6a6ea5
Show file tree
Hide file tree
Showing 27 changed files with 5,194 additions and 30 deletions.
74 changes: 62 additions & 12 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
@@ -1,36 +1,54 @@
name: Linux
name: config

on:
push:
branches:
- master
tags-ignore:
- "**"
paths-ignore:
- "**.md"
- stable
pull_request:
paths-ignore:
- "**.md"
branches:
- master
- stable

jobs:
golang:
name: Build (Go ${{ matrix.go }}, OS ${{matrix.os}})
config_test:
name: Config plugin (Go ${{ matrix.go }}, PHP ${{ matrix.php }}, OS ${{matrix.os}})
runs-on: ${{ matrix.os }}
timeout-minutes: 60
strategy:
fail-fast: true
matrix:
php: [ "8.2" ]
go: [ stable ]
os: ["ubuntu-latest"]
os: [ "ubuntu-latest" ]
steps:
- name: Set up Go ${{ matrix.go }}
uses: actions/setup-go@v4 # action page: <https://github.com/actions/setup-go>
with:
go-version: ${{ matrix.go }}

- name: Set up PHP ${{ matrix.php }}
uses: shivammathur/setup-php@v2 # action page: <https://github.com/shivammathur/setup-php>
with:
php-version: ${{ matrix.php }}
extensions: sockets

- name: Check out code
uses: actions/checkout@v4

- name: Get Composer Cache Directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Init Composer Cache # Docs: <https://git.io/JfAKn#php---composer>
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ matrix.php }}-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-

- name: Install Composer dependencies
run: cd tests/php_test_files && composer update --prefer-dist --no-progress --ansi

- name: Init Go modules Cache # Docs: <https://git.io/JfAKn#go---modules>
uses: actions/cache@v3
with:
Expand All @@ -42,4 +60,36 @@ jobs:
run: go mod download

- name: Run golang tests with coverage
run: make test
run: |
cd tests
mkdir ./coverage-ci
go test -timeout 20m -v -race -cover -tags=debug -failfast -coverpkg=$(cat pkgs.txt) -coverprofile=./coverage-ci/config.out -covermode=atomic ./...
- name: Archive code coverage results
uses: actions/upload-artifact@v3
with:
name: coverage
path: ./tests/coverage-ci/config.out

codecov:
name: Upload codecov
runs-on: ubuntu-latest
needs:
- config_test

timeout-minutes: 60
steps:
- name: Download code coverage results
uses: actions/download-artifact@v3
- run: |
cd coverage
echo 'mode: atomic' > summary.txt
tail -q -n +2 *.out >> summary.txt
sed -i '2,${/roadrunner/!d}' summary.txt
- name: upload to codecov
uses: codecov/codecov-action@v3 # Docs: <https://github.com/codecov/codecov-action>
with:
file: ./coverage/summary.txt
fail_ci_if_error: false
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@
*.out

# Dependency directories (remove the comment below to include it)
# vendor/
vendor/
.idea
1 change: 0 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ linters: # All available linters list: <https://golangci-lint.run/usage/linters/
- asciicheck # Simple linter to check that your code does not contain non-ASCII identifiers
- bodyclose # Checks whether HTTP response body is closed successfully
- dogsled # Checks assignments with too many blank identifiers (e.g. x, _, _, _, := f())
- dupl # Tool for code clone detection
- errcheck # Errcheck is a program for checking for unchecked errors in go programs. These unchecked errors can be critical bugs in some cases
- errorlint # find code that will cause problems with the error wrapping scheme introduced in Go 1.13
- exhaustive # check exhaustiveness of enum switch statements
Expand Down
6 changes: 6 additions & 0 deletions .vale.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
StylesPath = .vale-styles

MinAlertLevel = suggestion

[*.md]
BasedOnStyles = Vale
5 changes: 1 addition & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,19 @@ module github.com/roadrunner-server/config/v4

go 1.21

toolchain go1.21.0
toolchain go1.21.1

require (
github.com/roadrunner-server/errors v1.3.0
github.com/spf13/viper v1.16.0
github.com/stretchr/testify v1.8.4
)

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/pelletier/go-toml/v2 v2.1.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/spf13/afero v1.10.0 // indirect
github.com/spf13/cast v1.5.1 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
Expand Down
6 changes: 6 additions & 0 deletions go.work
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
go 1.21.1

use (
.
./tests
)
Loading

0 comments on commit c6a6ea5

Please sign in to comment.