Files
supermq/.semaphore/semaphore.yml
T
2023-10-26 12:50:56 +02:00

708 lines
22 KiB
YAML

version: v1.0
name: CI Pipeline
agent:
machine:
type: e1-standard-2
os_image: ubuntu2004
auto_cancel:
running:
when: branch != 'master'
global_job_config:
prologue:
commands:
- checkout
- sem-version go 1.21
blocks:
- name: Setup
dependencies: []
task:
jobs:
- name: Setup Codecov
commands:
- "curl -Os https://uploader.codecov.io/latest/linux/codecov"
- chmod +x codecov
- ./codecov
- cache store codecov ./codecov
- name: Setup Golangci-lint
commands:
- "curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.53.3"
- cache store linter ./bin/golangci-lint
secrets:
- name: codecov
- name: Check Generated Protocol Buffer Files
dependencies: []
run:
when: "change_in(['./auth.proto', 'pkg/messaging/message.proto'])"
task:
jobs:
- name: Check Generated Protocol Buffer Files
commands:
- PROTOC_VERSION=24.3
- PROTOC_GEN_VERSION=v1.31.0
- PROTOC_GRPC_VERSION=v1.3.0
- PROTOC_ZIP=protoc-$PROTOC_VERSION-linux-x86_64.zip
- curl -0L https://github.com/google/protobuf/releases/download/v$PROTOC_VERSION/$PROTOC_ZIP -o $PROTOC_ZIP
- unzip -o $PROTOC_ZIP -d protoc3
- sudo mv protoc3/bin/* /usr/local/bin/
- sudo mv protoc3/include/* /usr/local/include/
- rm -rf $PROTOC_ZIP protoc3
- go install google.golang.org/protobuf/cmd/protoc-gen-go@$PROTOC_GEN_VERSION
- go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@$PROTOC_GRPC_VERSION
- export PATH=$PATH:/usr/local/bin/protoc
- export PATH=$PATH:$HOME/go/bin
- |
echo "Setting up Magistrala..."
for p in $(ls ./*.pb.go); do
mv $p $p.tmp
done
for p in $(ls pkg/messaging/*.pb.go); do
mv $p $p.tmp
done
- make proto
- |
for p in $(ls ./*.pb.go); do
if ! cmp -s $p $p.tmp; then
echo "Proto file and generated Go file $p are out of sync!"
exit 1
fi
done
- |
for p in $(ls pkg/messaging/*.pb.go); do
if ! cmp -s $p $p.tmp; then
echo "Proto file and generated Go file $p are out of sync!"
exit 1
fi
done
- name: Lint and Test Users
run:
when: "change_in(['users', 'cmd/users', 'auth/service.go', 'auth/api/grpc/client.go'])"
dependencies:
- Setup
- Check Generated Protocol Buffer Files
task:
jobs:
- name: Lint Users
commands:
- cd users
- cache restore linter
- "./bin/golangci-lint run"
- name: Test Users
commands:
- cd users
- go test ./... --race -v -coverprofile=coverage.out
- go tool cover -html=coverage.out -o coverage.html
- cache restore codecov
- ./codecov
secrets:
- name: codecov
- name: Build Users
dependencies:
- Lint and Test Users
run:
when: "change_in(['users', 'cmd/users'])"
task:
jobs:
- name: Build Users
commands:
- make docker_users
secrets:
- name: docker_hub
- name: Lint and Test Things
run:
when: "change_in(['things', 'cmd/things', 'auth/service.go', 'auth/api/grpc/client.go'])"
dependencies:
- Setup
- Check Generated Protocol Buffer Files
task:
jobs:
- name: Lint Things
commands:
- cd things
- cache restore linter
- "./bin/golangci-lint run"
- name: Test Things
commands:
- cd things
- go test ./... --race -v -coverprofile=coverage.out
- go tool cover -html=coverage.out -o coverage.html
- cache restore codecov
- ./codecov
secrets:
- name: codecov
- name: Build Things
dependencies:
- Lint and Test Things
run:
when: "change_in(['things', 'cmd/things'])"
task:
jobs:
- name: Build Things
commands:
- make docker_things
secrets:
- name: docker_hub
- name: Lint and Test CoAP
run:
when: "change_in(['coap', 'cmd/coap', 'things/api/grpc', 'auth/service.go', 'auth/api/grpc/client.go'])"
dependencies:
- Setup
- Check Generated Protocol Buffer Files
task:
jobs:
- name: Lint CoAP
commands:
- cd coap
- cache restore linter
- "./bin/golangci-lint run"
- name: Test CoAP
commands:
- cd coap
- go test ./... --race -v -coverprofile=coverage.out
- go tool cover -html=coverage.out -o coverage.html
- cache restore codecov
- ./codecov
secrets:
- name: codecov
- name: Build CoAP
dependencies:
- Lint and Test CoAP
run:
when: "change_in(['coap', 'cmd/coap'])"
task:
jobs:
- name: Build CoAP
commands:
- make docker_coap
secrets:
- name: docker_hub
- name: Lint and Test HTTP
run:
when: "change_in(['http', 'cmd/http', 'things/api/grpc', 'auth/service.go', 'auth/api/grpc/client.go'])"
dependencies:
- Setup
- Check Generated Protocol Buffer Files
task:
jobs:
- name: Lint HTTP
commands:
- cd http
- cache restore linter
- "./bin/golangci-lint run"
- name: Test HTTP
commands:
- cd http
- go test ./... --race -v -coverprofile=coverage.out
- go tool cover -html=coverage.out -o coverage.html
- cache restore codecov
- ./codecov
secrets:
- name: codecov
- name: Build HTTP
dependencies:
- Lint and Test HTTP
run:
when: "change_in(['http', 'cmd/http'])"
task:
jobs:
- name: Build HTTP
commands:
- echo $DOCKER_TOKEN | docker login --username "$DOCKER_USERNAME" --password-stdin
- docker push magistrala/http:latest
secrets:
- name: docker_hub
- name: Lint and Test MQTT
run:
when: "change_in(['mqtt', 'cmd/mqtt', 'things/api/grpc', 'auth/service.go', 'auth/api/grpc/client.go'])"
dependencies:
- Setup
- Check Generated Protocol Buffer Files
task:
jobs:
- name: Lint MQTT
commands:
- cd mqtt
- cache restore linter
- "./bin/golangci-lint run"
- name: Test MQTT
commands:
- cd mqtt
- go test ./... --race -v -coverprofile=coverage.out
- go tool cover -html=coverage.out -o coverage.html
- cache restore codecov
- ./codecov
secrets:
- name: codecov
- name: Build MQTT
dependencies:
- Lint and Test MQTT
run:
when: "change_in(['mqtt', 'cmd/mqtt'])"
task:
jobs:
- name: Build MQTT
commands:
- echo $DOCKER_TOKEN | docker login --username "$DOCKER_USERNAME" --password-stdin
- docker push magistrala/mqtt:latest
secrets:
- name: docker_hub
- name: Lint and Test WS
run:
when: "change_in(['ws', 'cmd/ws', 'things/api/grpc', 'auth/service.go', 'auth/api/grpc/client.go'])"
dependencies:
- Setup
- Check Generated Protocol Buffer Files
task:
jobs:
- name: Lint WS
commands:
- cd ws
- cache restore linter
- "./bin/golangci-lint run"
- name: Test WS
commands:
- cd ws
- go test ./... --race -v -coverprofile=coverage.out
- go tool cover -html=coverage.out -o coverage.html
- cache restore codecov
- ./codecov
secrets:
- name: codecov
- name: Build WS
dependencies:
- Lint and Test WS
run:
when: "change_in(['ws', 'cmd/ws', 'things/api/grpc', 'auth/service.go', 'auth/api/grpc/client.go'])"
task:
jobs:
- name: Build WS
commands:
- echo $DOCKER_TOKEN | docker login --username "$DOCKER_USERNAME" --password-stdin
- docker push magistrala/ws:latest
secrets:
- name: docker_hub
- name: Lint and Test Bootstrap
run:
when: "change_in(['bootstrap', 'cmd/bootstrap','things/policies/postgres/policies.go', 'things/policies/api/grpc/client.go'])"
dependencies:
- Setup
- Check Generated Protocol Buffer Files
task:
jobs:
- name: Lint Bootstrap
commands:
- cd bootstrap
- cache restore linter
- "./bin/golangci-lint run"
- name: Test Bootstrap
commands:
- cd bootstrap
- go test ./... --race -v -coverprofile=coverage.out
- go tool cover -html=coverage.out -o coverage.html
- cache restore codecov
- ./codecov
secrets:
- name: codecov
- name: Build Bootstrap
dependencies:
- Lint and Test Bootstrap
run:
when: "change_in(['bootstrap', 'cmd/bootstrap'])"
task:
jobs:
- name: Build Bootstrap
commands:
- echo $DOCKER_TOKEN | docker login --username "$DOCKER_USERNAME" --password-stdin
- docker push magistrala/bootstrap:latest
secrets:
- name: docker_hub
- name: Lint and Test Certs
run:
when: "change_in(['certs', 'cmd/certs', 'things/api/grpc', 'auth/service.go', 'auth/api/grpc/client.go'])"
dependencies:
- Setup
- Check Generated Protocol Buffer Files
task:
jobs:
- name: Lint Certs
commands:
- cd certs
- cache restore linter
- "./bin/golangci-lint run"
- name: Test Certs
commands:
- cd certs
- go test ./... --race -v -coverprofile=coverage.out
- go tool cover -html=coverage.out -o coverage.html
- cache restore codecov
- ./codecov
secrets:
- name: codecov
- name: Build Certs
dependencies:
- Lint and Test Certs
run:
when: "change_in(['certs', 'cmd/certs'])"
task:
jobs:
- name: Build Certs
commands:
- echo $DOCKER_TOKEN | docker login --username "$DOCKER_USERNAME" --password-stdin
- docker push magistrala/certs:latest
secrets:
- name: docker_hub
- name: Lint and Test Provision
dependencies:
- Setup
- Check Generated Protocol Buffer Files
run:
when: "change_in(['provision', 'cmd/provision'])"
task:
jobs:
- name: Lint Provision
commands:
- cd provision
- cache restore linter
- "./bin/golangci-lint run"
- name: Test Provision
commands:
- cd provision
- go test ./... --race -v -coverprofile=coverage.out
- go tool cover -html=coverage.out -o coverage.html
- cache restore codecov
- ./codecov
secrets:
- name: codecov
- name: Build Provision
dependencies:
- Lint and Test Provision
run:
when: "change_in(['provision', 'cmd/provision', 'things/api/grpc', 'auth/service.go', 'auth/api/grpc/client.go'])"
task:
jobs:
- name: Build Provision
commands:
- echo $DOCKER_TOKEN | docker login --username "$DOCKER_USERNAME" --password-stdin
- docker push magistrala/http:latest
secrets:
- name: docker_hub
- name: Lint and Test Twins
run:
when: "change_in(['twins', 'cmd/twins', 'things/api/grpc', 'auth/service.go', 'auth/api/grpc/client.go'])"
dependencies:
- Setup
- Check Generated Protocol Buffer Files
task:
jobs:
- name: Lint Twins
commands:
- cd twins
- cache restore linter
- "./bin/golangci-lint run"
- name: Test Twins
commands:
- cd twins
- go test ./... --race -v -coverprofile=coverage.out
- go tool cover -html=coverage.out -o coverage.html
- cache restore codecov
- ./codecov
secrets:
- name: codecov
- name: Build Twins
dependencies:
- Lint and Test Twins
run:
when: "change_in(['twins', 'cmd/twins'])"
task:
jobs:
- name: Build Twins
commands:
- echo $DOCKER_TOKEN | docker login --username "$DOCKER_USERNAME" --password-stdin
- docker push magistrala/twins:latest
secrets:
- name: docker_hub
- name: Lint and Test Readers
run:
when: "change_in(['/readers', 'cmd/cassandra-reader', 'cmd/influxdb-reader', 'cmd/mongodb-reader', 'cmd/postgres-reader', 'cmd/timescale-reader', 'things/api/grpc', 'auth/service.go', 'auth/api/grpc/client.go'])"
dependencies:
- Setup
- Check Generated Protocol Buffer Files
task:
jobs:
- name: Lint Readers
commands:
- cd readers
- cache restore linter
- "./bin/golangci-lint run"
- name: Test Twins
commands:
- cd readers
- go test ./... --race -v -coverprofile=coverage.out
- go tool cover -html=coverage.out -o coverage.html
- cache restore codecov
- ./codecov
secrets:
- name: codecov
- name: Build Readers
dependencies:
- Lint and Test Readers
run:
when: "change_in(['readers', 'cmd/cassandra-reader', 'cmd/influxdb-reader', 'cmd/mongodb-reader', 'cmd/postgres-reader', 'cmd/timescale-reader', 'things/api/grpc', 'auth/service.go', 'auth/api/grpc/client.go'])"
task:
jobs:
- name: Build Readers
commands:
- echo $DOCKER_TOKEN | docker login --username "$DOCKER_USERNAME" --password-stdin
- docker push magistrala/cassandra-reader:latest
- docker push magistrala/influxdb-reader:latest
- docker push magistrala/mongodb-reader:latest
- docker push magistrala/postgres-reader:latest
- docker push magistrala/timescale-reader:latest
secrets:
- name: docker_hub
- name: Lint and Test Consumers
run:
when: "change_in(['consumers', 'cmd/cassandra-writer', 'cmd/influxdb-writer', 'cmd/mongodb-writer', 'cmd/postgres-writer', 'cmd/timescale-writer', 'cmd/smpp-notifier', 'cmd/smtp-notifier', 'things/api/grpc', 'auth/service.go', 'auth/api/grpc/client.go'])"
dependencies:
- Setup
- Check Generated Protocol Buffer Files
task:
jobs:
- name: Lint Consumers
commands:
- cd consumers
- cache restore linter
- "./bin/golangci-lint run"
- name: Test Consumers
commands:
- cd consumers
- go test ./... --race -v -coverprofile=coverage.out
- go tool cover -html=coverage.out -o coverage.html
- cache restore codecov
- ./codecov
secrets:
- name: codecov
- name: Build Consumers
dependencies:
- Lint and Test Consumers
run:
when: "change_in(['consumers', 'cmd/cassandra-writer', 'cmd/influxdb-writer', 'cmd/mongodb-writer', 'cmd/postgres-writer', 'cmd/timescale-writer', 'cmd/smpp-notifier', 'cmd/smtp-notifier', 'things/api/grpc', 'auth/service.go', 'auth/api/grpc/client.go'])"
task:
jobs:
- name: Build Consumers
commands:
- echo $DOCKER_TOKEN | docker login --username "$DOCKER_USERNAME" --password-stdin
- docker push magistrala/cassandra-writer:latest
- docker push magistrala/influxdb-writer:latest
- docker push magistrala/mongodb-writer:latest
- docker push magistrala/postgres-writer:latest
- docker push magistrala/timescale-writer:latest
- docker push magistrala/smtp-notifier:latest
secrets:
- name: docker_hub
- name: Lint and Test CLI
run:
when: "change_in(['cli', 'cmd/cli'])"
dependencies:
- Setup
- Check Generated Protocol Buffer Files
task:
jobs:
- name: Lint CLI
commands:
- cd cli
- cache restore linter
- "./bin/golangci-lint run"
- name: Test CLI
commands:
- cd cli
- go test ./... --race -v -coverprofile=coverage.out
- go tool cover -html=coverage.out -o coverage.html
- cache restore codecov
- ./codecov
secrets:
- name: codecov
- name: Build CLI
dependencies:
- Lint and Test CLI
run:
when: "change_in(['cli', 'cmd/cli'])"
task:
jobs:
- name: Build CLI
commands:
- echo $DOCKER_TOKEN | docker login --username "$DOCKER_USERNAME" --password-stdin
- docker push magistrala/cli:latest
secrets:
- name: docker_hub
- name: Lint and Test LoRa
run:
when: "change_in(['lora', 'cmd/lora'])"
dependencies:
- Setup
- Check Generated Protocol Buffer Files
task:
jobs:
- name: Lint LoRa
commands:
- cd lora
- cache restore linter
- "./bin/golangci-lint run"
- name: Test LoRa
commands:
- cd lora
- go test ./... --race -v -coverprofile=coverage.out
- go tool cover -html=coverage.out -o coverage.html
- cache restore codecov
- ./codecov
secrets:
- name: codecov
- name: Build LoRa
dependencies:
- Lint and Test LoRa
run:
when: "change_in(['lora', 'cmd/lora'])"
task:
jobs:
- name: Build LoRa
commands:
- echo $DOCKER_TOKEN | docker login --username "$DOCKER_USERNAME" --password-stdin
- docker push magistrala/lora:latest
secrets:
- name: docker_hub
- name: Lint and Test OPC-UA
run:
when: "change_in(['/opcua', 'cmd/opcua', 'things/api/grpc', 'auth/service.go', 'auth/api/grpc/client.go'])"
dependencies:
- Setup
- Check Generated Protocol Buffer Files
task:
jobs:
- name: Lint OPC-UA
commands:
- cd opcua
- cache restore linter
- "./bin/golangci-lint run"
- name: Test OPC-UA
commands:
- cd opcua
- go test ./... --race -v -coverprofile=coverage.out
- go tool cover -html=coverage.out -o coverage.html
- cache restore codecov
- ./codecov
secrets:
- name: codecov
- name: Build OPC-UA
dependencies:
- Lint and Test OPC-UA
run:
when: "change_in(['/opcua', 'cmd/opcua'])"
task:
jobs:
- name: Build OPC-UA
commands:
- echo $DOCKER_TOKEN | docker login --username "$DOCKER_USERNAME" --password-stdin
- docker push magistrala/opcua:latest
secrets:
- name: docker_hub
- name: Lint and Test Internal
run:
when: "change_in('/internal')"
dependencies:
- Setup
- Check Generated Protocol Buffer Files
task:
jobs:
- name: Lint Internal
commands:
- cd internal
- cache restore linter
- "./bin/golangci-lint run"
- name: Test Internal
commands:
- cd internal
- go test ./... --race -v -coverprofile=coverage.out
- go tool cover -html=coverage.out -o coverage.html
- cache restore codecov
- ./codecov
- name: Lint and Test Logger
run:
when: "change_in('/logger')"
dependencies:
- Setup
- Check Generated Protocol Buffer Files
task:
jobs:
- name: Lint Logger
commands:
- cd logger
- cache restore linter
- "./bin/golangci-lint run"
- name: Test Logger
commands:
- cd logger
- go test ./... --race -v -coverprofile=coverage.out
- go tool cover -html=coverage.out -o coverage.html
- cache restore codecov
- ./codecov
- name: Lint and Test PKG
run:
when: "change_in('/pkg')"
dependencies:
- Setup
- Check Generated Protocol Buffer Files
task:
jobs:
- name: Lint PKG
commands:
- cd pkg
- cache restore linter
- "./bin/golangci-lint run"
- name: Test PKG
commands:
- cd pkg
- go test ./... --race -v -coverprofile=coverage.out
- go tool cover -html=coverage.out -o coverage.html
- cache restore codecov
- ./codecov
- name: Lint and Test Tools
run:
when: "change_in('/tools')"
dependencies:
- Setup
- Check Generated Protocol Buffer Files
task:
jobs:
- name: Lint Tools
commands:
- cd tools
- cache restore linter
- "./bin/golangci-lint run"
- name: Test Tools
commands:
- cd tools
- go test ./... --race -v -coverprofile=coverage.out
- go tool cover -html=coverage.out -o coverage.html
- cache restore codecov
- ./codecov
- name: Compile Check For RabbitMQ
dependencies:
- Setup
task:
jobs:
- name: Compile For RabbitMQ
commands:
- MG_MESSAGE_BROKER_TYPE=rabbitmq make mqtt
- name: Compile Check For Redis
dependencies:
- Setup
task:
jobs:
- name: Compile For Redis
commands:
- MG_ES_STORE_TYPE=redis make mqtt