Performance and bug-fix backports #445
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Tests | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
# Run golangci-lint | |
lint: | |
timeout-minutes: 5 | |
name: Linting | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Install Go | |
uses: actions/setup-go@v3 | |
with: | |
go-version: 1.22 | |
- name: golangci-lint | |
uses: golangci/golangci-lint-action@v3 | |
# run go test with different go versions | |
test: | |
timeout-minutes: 5 | |
name: Unit tests (Go ${{ matrix.go }}) | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
go: ["stable", "1.22"] | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Setup go | |
uses: actions/setup-go@v3 | |
with: | |
go-version: ${{ matrix.go }} | |
- uses: actions/cache@v3 | |
with: | |
path: | | |
~/.cache/go-build | |
~/go/pkg/mod | |
key: ${{ runner.os }}-go${{ matrix.go }}-test-${{ hashFiles('**/go.sum') }} | |
restore-keys: | | |
${{ runner.os }}-go${{ matrix.go }}-test- | |
- run: go test -race -coverpkg=./... -coverprofile=cover.out $(go list ./...) | |
- name: Upload coverage to Codecov | |
uses: codecov/codecov-action@v4 | |
with: | |
fail_ci_if_error: true | |
token: ${{ secrets.CODECOV_TOKEN }} | |
# run go test on Dendrite with different go versions | |
test-dendrite: | |
timeout-minutes: 10 | |
name: Unit tests Dendrite (Go ${{ matrix.go }}) | |
runs-on: ubuntu-latest | |
# Service containers to run with `container-job` | |
services: | |
# Label used to access the service container | |
postgres: | |
# Docker Hub image | |
image: postgres:13-alpine | |
# Provide the password for postgres | |
env: | |
POSTGRES_USER: postgres | |
POSTGRES_PASSWORD: postgres | |
POSTGRES_DB: dendrite | |
ports: | |
# Maps tcp port 5432 on service container to the host | |
- 5432:5432 | |
# Set health checks to wait until postgres has started | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
strategy: | |
fail-fast: false | |
matrix: | |
go: ["stable", "1.22"] | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
repository: "matrix-org/dendrite" | |
- name: Install libolm | |
run: sudo apt-get install libolm-dev libolm3 | |
- name: Setup go | |
uses: actions/setup-go@v3 | |
with: | |
go-version: ${{ matrix.go }} | |
- uses: actions/cache@v3 | |
with: | |
path: | | |
~/.cache/go-build | |
~/go/pkg/mod | |
key: ${{ runner.os }}-go${{ matrix.go }}-test-${{ hashFiles('**/go.sum') }} | |
restore-keys: | | |
${{ runner.os }}-go${{ matrix.go }}-test- | |
- if: github.event_name == 'pull_request' | |
env: | |
REPOSITORY: ${{ github.event.pull_request.head.repo.full_name }} | |
PULL_SHA: ${{ github.event.pull_request.head.sha }} | |
# Replace matrix-org/gomatrixserverlib with the repository sending the pull request | |
run: go mod edit -replace "github.com/matrix-org/gomatrixserverlib=github.com/${REPOSITORY}@${PULL_SHA}" && go mod tidy | |
- if: github.ref_name == 'main' | |
run: go get github.com/matrix-org/gomatrixserverlib@${{ github.sha }} && go mod tidy | |
- run: go test ./... | |
env: | |
POSTGRES_HOST: localhost | |
POSTGRES_USER: postgres | |
POSTGRES_PASSWORD: postgres | |
POSTGRES_DB: dendrite |