MG-1744 - Improve error handling #9
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
# Copyright (c) Abstract Machines | |
# SPDX-License-Identifier: Apache-2.0 | |
name: CI Pipeline | |
on: | |
pull_request: | |
branches: | |
- main | |
jobs: | |
lint-and-build: # Linting and building are combined to save time for setting up Go | |
name: Lint and Build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v4 | |
- name: Setup Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: 1.22.x | |
cache-dependency-path: "go.sum" | |
- name: golangci-lint | |
uses: golangci/golangci-lint-action@v6 | |
with: | |
version: v1.57.2 | |
- name: Build all Binaries | |
run: | | |
make all -j $(nproc) | |
- name: Compile check for rabbitmq | |
run: | | |
MG_MESSAGE_BROKER_TYPE=rabbitmq make mqtt | |
- name: Compile check for redis | |
run: | | |
MG_ES_TYPE=redis make mqtt | |
run-tests: | |
name: Run tests | |
runs-on: ubuntu-latest | |
needs: lint-and-build | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Setup Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: 1.22.x | |
cache-dependency-path: "go.sum" | |
- name: Check for changes in specific paths | |
uses: dorny/paths-filter@v3 | |
id: changes | |
with: | |
base: main | |
filters: | | |
workflow: | |
- ".github/workflows/tests.yml" | |
auth: | |
- "auth/**" | |
- "cmd/auth/**" | |
- "auth.proto" | |
- "auth.pb.go" | |
- "auth_grpc.pb.go" | |
- "pkg/ulid/**" | |
- "pkg/uuid/**" | |
bootstrap: | |
- "bootstrap/**" | |
- "cmd/bootstrap/**" | |
- "auth.pb.go" | |
- "auth_grpc.pb.go" | |
- "auth/**" | |
- "pkg/sdk/**" | |
- "pkg/events/**" | |
certs: | |
- "certs/**" | |
- "cmd/certs/**" | |
- "auth.pb.go" | |
- "auth_grpc.pb.go" | |
- "auth/**" | |
- "pkg/sdk/**" | |
coap: | |
- "coap/**" | |
- "cmd/coap/**" | |
- "auth.pb.go" | |
- "auth_grpc.pb.go" | |
- "things/**" | |
- "pkg/messaging/**" | |
consumers: | |
- "consumers/**" | |
- "cmd/cassandra-writer/**" | |
- "cmd/influxdb-writer/**" | |
- "cmd/mongodb-writer/**" | |
- "cmd/postgres-writer/**" | |
- "cmd/timescale-writer/**" | |
- "cmd/smpp-notifier/**" | |
- "cmd/smtp-notifier/**" | |
- "auth.pb.go" | |
- "auth_grpc.pb.go" | |
- "auth/**" | |
- "pkg/ulid/**" | |
- "pkg/uuid/**" | |
- "pkg/messaging/**" | |
http: | |
- "http/**" | |
- "cmd/http/**" | |
- "auth.pb.go" | |
- "auth_grpc.pb.go" | |
- "things/**" | |
- "pkg/messaging/**" | |
- "logger/**" | |
internal: | |
- "internal/**" | |
invitations: | |
- "invitations/**" | |
- "cmd/invitations/**" | |
- "auth.pb.go" | |
- "auth_grpc.pb.go" | |
- "auth/**" | |
- "pkg/sdk/**" | |
lora: | |
- "lora/**" | |
- "cmd/lora/**" | |
- "pkg/messaging/**" | |
logger: | |
- "logger/**" | |
mqtt: | |
- "mqtt/**" | |
- "cmd/mqtt/**" | |
- "auth.pb.go" | |
- "auth_grpc.pb.go" | |
- "things/**" | |
- "pkg/messaging/**" | |
- "logger/**" | |
- "pkg/events/**" | |
opcua: | |
- "opcua/**" | |
- "cmd/opcua/**" | |
- "logger/**" | |
pkg-auth: | |
- "pkg/auth/**" | |
pkg-clients: | |
- "pkg/clients/**" | |
pkg-errors: | |
- "pkg/errors/**" | |
pkg-events: | |
- "pkg/events/**" | |
- "pkg/messaging/**" | |
pkg-messaging: | |
- "pkg/messaging/**" | |
pkg-sdk: | |
- "pkg/sdk/**" | |
- "pkg/clients/**" | |
- "pkg/errors/**" | |
- "pkg/groups/**" | |
- "auth/**" | |
- "bootstrap/**" | |
- "certs/**" | |
- "consumers/**" | |
- "http/**" | |
- "internal/*" | |
- "internal/api/**" | |
- "internal/apiutil/**" | |
- "internal/groups/**" | |
- "invitations/**" | |
- "provision/**" | |
- "readers/**" | |
- "things/**" | |
- "twins/**" | |
- "users/**" | |
pkg-transformers: | |
- "pkg/transformers/**" | |
pkg-ulid: | |
- "pkg/ulid/**" | |
pkg-uuid: | |
- "pkg/uuid/**" | |
provision: | |
- "provision/**" | |
- "cmd/provision/**" | |
- "logger/**" | |
- "pkg/sdk/**" | |
readers: | |
- "readers/**" | |
- "cmd/cassandra-reader/**" | |
- "cmd/influxdb-reader/**" | |
- "cmd/mongodb-reader/**" | |
- "cmd/postgres-reader/**" | |
- "cmd/timescale-reader/**" | |
- "auth.pb.go" | |
- "auth_grpc.pb.go" | |
- "things/**" | |
- "auth/**" | |
things: | |
- "things/**" | |
- "cmd/things/**" | |
- "auth.pb.go" | |
- "auth_grpc.pb.go" | |
- "auth/**" | |
- "pkg/clients/**" | |
- "pkg/ulid/**" | |
- "pkg/uuid/**" | |
- "pkg/events/**" | |
twins: | |
- "twins/**" | |
- "cmd/twins/**" | |
- "auth.pb.go" | |
- "auth_grpc.pb.go" | |
- "auth/**" | |
- "pkg/messaging/**" | |
- "pkg/ulid/**" | |
- "pkg/uuid/**" | |
- "logger/**" | |
users: | |
- "users/**" | |
- "cmd/users/**" | |
- "auth.pb.go" | |
- "auth_grpc.pb.go" | |
- "auth/**" | |
- "pkg/clients/**" | |
- "pkg/ulid/**" | |
- "pkg/uuid/**" | |
- "pkg/events/**" | |
ws: | |
- "ws/**" | |
- "cmd/ws/**" | |
- "auth.pb.go" | |
- "auth_grpc.pb.go" | |
- "things/**" | |
- "pkg/messaging/**" | |
- name: Create coverage directory | |
run: | | |
mkdir coverage | |
- name: Run auth tests | |
if: steps.changes.outputs.auth == 'true' || steps.changes.outputs.workflow == 'true' | |
run: | | |
go test --race -v -count=1 -coverprofile=coverage/auth.out ./auth/... | |
- name: Run bootstrap tests | |
if: steps.changes.outputs.bootstrap == 'true' || steps.changes.outputs.workflow == 'true' | |
run: | | |
go test --race -v -count=1 -coverprofile=coverage/bootstrap.out ./bootstrap/... | |
- name: Run certs tests | |
if: steps.changes.outputs.certs == 'true' || steps.changes.outputs.workflow == 'true' | |
run: | | |
go test --race -v -count=1 -coverprofile=coverage/certs.out ./certs/... | |
- name: Run CoAP tests | |
if: steps.changes.outputs.coap == 'true' || steps.changes.outputs.workflow == 'true' | |
run: | | |
go test --race -v -count=1 -coverprofile=coverage/coap.out ./coap/... | |
- name: Run consumers tests | |
if: steps.changes.outputs.consumers == 'true' || steps.changes.outputs.workflow == 'true' | |
run: | | |
go test --race -v -count=1 -coverprofile=coverage/consumers.out ./consumers/... | |
- name: Run HTTP tests | |
if: steps.changes.outputs.http == 'true' || steps.changes.outputs.workflow == 'true' | |
run: | | |
go test --race -v -count=1 -coverprofile=coverage/http.out ./http/... | |
- name: Run internal tests | |
if: steps.changes.outputs.internal == 'true' || steps.changes.outputs.workflow == 'true' | |
run: | | |
go test --race -v -count=1 -coverprofile=coverage/internal.out ./internal/... | |
- name: Run invitations tests | |
if: steps.changes.outputs.invitations == 'true' || steps.changes.outputs.workflow == 'true' | |
run: | | |
go test --race -v -count=1 -coverprofile=coverage/invitations.out ./invitations/... | |
- name: Run logger tests | |
if: steps.changes.outputs.logger == 'true' || steps.changes.outputs.workflow == 'true' | |
run: | | |
go test --race -v -count=1 -coverprofile=coverage/logger.out ./logger/... | |
- name: Run LoRa tests | |
if: steps.changes.outputs.lora == 'true' || steps.changes.outputs.workflow == 'true' | |
run: | | |
go test --race -v -count=1 -coverprofile=coverage/lora.out ./lora/... | |
- name: Run MQTT tests | |
if: steps.changes.outputs.mqtt == 'true' || steps.changes.outputs.workflow == 'true' | |
run: | | |
go test --race -v -count=1 -coverprofile=coverage/mqtt.out ./mqtt/... | |
- name: Run OPC-UA tests | |
if: steps.changes.outputs.opcua == 'true' || steps.changes.outputs.workflow == 'true' | |
run: | | |
go test --race -v -count=1 -coverprofile=coverage/opcua.out ./opcua/... | |
- name: Run pkg auth tests | |
if: steps.changes.outputs.pkg-auth == 'true' || steps.changes.outputs.workflow == 'true' | |
run: | | |
go test --race -v -count=1 -coverprofile=coverage/pkg-auth.out ./pkg/auth/... | |
- name: Run pkg clients tests | |
if: steps.changes.outputs.pkg-clients == 'true' || steps.changes.outputs.workflow == 'true' | |
run: | | |
go test --race -v -count=1 -coverprofile=coverage/pkg-clients.out ./pkg/clients/... | |
- name: Run pkg errors tests | |
if: steps.changes.outputs.pkg-errors == 'true' || steps.changes.outputs.workflow == 'true' | |
run: | | |
go test --race -v -count=1 -coverprofile=coverage/pkg-errors.out ./pkg/errors/... | |
- name: Run pkg events tests | |
if: steps.changes.outputs.pkg-events == 'true' || steps.changes.outputs.workflow == 'true' | |
run: | | |
go test --race -v -count=1 -coverprofile=coverage/pkg-events.out ./pkg/events/... | |
- name: Run pkg messaging tests | |
if: steps.changes.outputs.pkg-messaging == 'true' || steps.changes.outputs.workflow == 'true' | |
run: | | |
go test --race -v -count=1 -coverprofile=coverage/pkg-messaging.out ./pkg/messaging/... | |
- name: Run pkg sdk tests | |
if: steps.changes.outputs.pkg-sdk == 'true' || steps.changes.outputs.workflow == 'true' | |
run: | | |
go test --race -v -count=1 -coverprofile=coverage/pkg-sdk.out ./pkg/sdk/... | |
- name: Run pkg transformers tests | |
if: steps.changes.outputs.pkg-transformers == 'true' || steps.changes.outputs.workflow == 'true' | |
run: | | |
go test --race -v -count=1 -coverprofile=coverage/pkg-transformers.out ./pkg/transformers/... | |
- name: Run pkg ulid tests | |
if: steps.changes.outputs.pkg-ulid == 'true' || steps.changes.outputs.workflow == 'true' | |
run: | | |
go test --race -v -count=1 -coverprofile=coverage/pkg-ulid.out ./pkg/ulid/... | |
- name: Run pkg uuid tests | |
if: steps.changes.outputs.pkg-uuid == 'true' || steps.changes.outputs.workflow == 'true' | |
run: | | |
go test --race -v -count=1 -coverprofile=coverage/pkg-uuid.out ./pkg/uuid/... | |
- name: Run provision tests | |
if: steps.changes.outputs.provision == 'true' || steps.changes.outputs.workflow == 'true' | |
run: | | |
go test --race -v -count=1 -coverprofile=coverage/provision.out ./provision/... | |
- name: Run readers tests | |
if: steps.changes.outputs.readers == 'true' || steps.changes.outputs.workflow == 'true' | |
run: | | |
go test --race -v -count=1 -coverprofile=coverage/readers.out ./readers/... | |
- name: Run things tests | |
if: steps.changes.outputs.things == 'true' || steps.changes.outputs.workflow == 'true' | |
run: | | |
go test --race -v -count=1 -coverprofile=coverage/things.out ./things/... | |
- name: Run twins tests | |
if: steps.changes.outputs.twins == 'true' || steps.changes.outputs.workflow == 'true' | |
run: | | |
go test --race -v -count=1 -coverprofile=coverage/twins.out ./twins/... | |
- name: Run users tests | |
if: steps.changes.outputs.users == 'true' || steps.changes.outputs.workflow == 'true' | |
run: | | |
go test --race -v -count=1 -coverprofile=coverage/users.out ./users/... | |
- name: Run WebSocket tests | |
if: steps.changes.outputs.ws == 'true' || steps.changes.outputs.workflow == 'true' | |
run: | | |
go test --race -v -count=1 -coverprofile=coverage/ws.out ./ws/... | |
- name: Upload coverage | |
uses: codecov/codecov-action@v4 | |
with: | |
token: ${{ secrets.CODECOV }} | |
directory: ./coverage/ | |
name: codecov-umbrella | |
verbose: true |