Files
supermq/.github/workflows/tests.yaml
T
Felix Gateru f28a3e8390 MG-401 - Fix authorization error in Magistrala services (#400)
* chore: update SMQ version

Signed-off-by: Felix Gateru <felix.gateru@gmail.com>

* chore: run make fetch_supermq

Signed-off-by: Felix Gateru <felix.gateru@gmail.com>

* tests: fix provison tests

Signed-off-by: Felix Gateru <felix.gateru@gmail.com>

* ci(build.yaml): get go version from go mod

Signed-off-by: Felix Gateru <felix.gateru@gmail.com>

---------

Signed-off-by: Felix Gateru <felix.gateru@gmail.com>
2026-02-11 11:17:13 +01:00

204 lines
6.0 KiB
YAML

# 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@v6
- name: Get Go version from go.mod
id: go-version
run: echo "version=$(grep '^go ' go.mod | awk '{print $2}')" >> $GITHUB_OUTPUT
- name: Setup Go
uses: actions/setup-go@v6
with:
go-version: ${{ steps.go-version.outputs.version }}
cache-dependency-path: "go.sum"
- name: Set GOBIN
run: echo "GOBIN=$HOME/.local/bin" >> $GITHUB_ENV
- name: Add GOBIN to PATH
run: echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: Fetch SuperMQ
run: |
make fetch_supermq
if [[ -n $(git status --porcelain docker/supermq-docker) ]]; then
echo "SuperMQ docker file is not up to date. Please update it"
git diff docker/supermq-docker
exit 1
else
exit 0
fi
- name: Build all Binaries
run: |
make all -j $(nproc)
- name: Run linters
uses: golangci/golangci-lint-action@v9
with:
version: v2.4.0
args: --config ./tools/config/.golangci.yaml
run-tests:
name: Run tests
runs-on: ubuntu-latest
needs: lint-and-build
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Get Go version from go.mod
id: go-version
run: echo "version=$(grep '^go ' go.mod | awk '{print $2}')" >> $GITHUB_OUTPUT
- name: Setup Go
uses: actions/setup-go@v6
with:
go-version: ${{ steps.go-version.outputs.version }}
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.yaml"
bootstrap:
- "bootstrap/**"
- "cmd/bootstrap/**"
- "auth.pb.go"
- "auth_grpc.pb.go"
- "auth/**"
- "pkg/sdk/**"
- "pkg/events/**"
cli:
- "cli/**"
- "cmd/cli/**"
- "pkg/sdk/**"
consumers:
- "consumers/**"
- "cmd/postgres-writer/**"
- "cmd/timescale-writer/**"
- "cmd/smpp-notifier/**"
- "cmd/smtp-notifier/**"
internal:
- "internal/**"
pkg-events:
- "pkg/events/**"
- "pkg/messaging/**"
pkg-sdk:
- "pkg/sdk/**"
- "bootstrap/api/**"
- "consumers/notifiers/api/**"
provision:
- "provision/**"
- "cmd/provision/**"
- "logger/**"
- "pkg/sdk/**"
readers:
- "readers/**"
- "cmd/postgres-reader/**"
- "cmd/timescale-reader/**"
- "auth.pb.go"
- "auth_grpc.pb.go"
- "things/**"
- "auth/**"
re:
- "re/**"
- "cmd/re/**"
- "re/api/**"
alarms:
- "alarms/**"
- "cmd/alarms/**"
- name: Create coverage directory
run: |
mkdir coverage
- 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 cli tests
if: steps.changes.outputs.cli == 'true' || steps.changes.outputs.workflow == 'true'
run: |
go test --race -v -count=1 -coverprofile=coverage/cli.out ./cli/...
- 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 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 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 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 rule engine tests
if: steps.changes.outputs.re == 'true' || steps.changes.outputs.workflow == 'true'
run: |
go test --race -v -count=1 -coverprofile=coverage/re.out ./re/...
- name: Run reports tests
if: steps.changes.outputs.reports == 'true' || steps.changes.outputs.workflow == 'true'
run: |
go test --race -v -count=1 -coverprofile=coverage/reports.out ./reports/...
- name: Run alarms tests
if: steps.changes.outputs.alarms == 'true' || steps.changes.outputs.workflow == 'true'
run: |
go test --race -v -count=1 -coverprofile=coverage/alarms.out ./alarms/...
- name: Upload coverage
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV }}
files: ./coverage/*.out
verbose: true