DEV-3540 issue rels #2342
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
# yamllint disable rule:line-length | |
--- | |
name: Tests | |
# yamllint disable-line rule:truthy | |
on: | |
workflow_dispatch: | |
pull_request: | |
types: [opened] | |
push: | |
jobs: | |
Unit-Tests: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Set up Go 1.x | |
uses: actions/setup-go@v2 | |
with: | |
go-version: 1.22.3 | |
- name: Check out code into the Go module directory | |
uses: actions/checkout@v2 | |
- name: Test & Coverage | |
env: | |
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} | |
run: | | |
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter | |
chmod +x ./cc-test-reporter | |
./cc-test-reporter before-build | |
go test -coverprofile c.out -coverpkg ./... ./... | |
./cc-test-reporter format-coverage -o codeclimate.json --prefix $(go list -m) | |
- name: Upload Coverage Result Artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: codeclimate-unit | |
path: codeclimate.json | |
retention-days: 1 | |
- uses: actions/setup-python@v2 | |
- name: Run pre commit linting | |
uses: pre-commit/[email protected] | |
PostgreSQL-Integration-Tests: | |
runs-on: ubuntu-latest | |
services: | |
postgres: | |
image: postgres | |
env: | |
POSTGRES_DB: safetyculture_exporter_db | |
POSTGRES_USER: safetyculture_exporter | |
POSTGRES_PASSWORD: safetyculture_exporter | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
ports: | |
- 5432:5432 | |
steps: | |
- name: Set up Go 1.x | |
uses: actions/setup-go@v2 | |
with: | |
go-version: 1.22.3 | |
- name: Check out code into the Go module directory | |
uses: actions/checkout@v2 | |
- name: Test & Coverage | |
env: | |
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} | |
TEST_DB_DIALECT: postgres | |
TEST_DB_CONN_STRING: "postgresql://safetyculture_exporter:safetyculture_exporter@localhost:5432/safetyculture_exporter_db" | |
run: | | |
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter | |
chmod +x ./cc-test-reporter | |
./cc-test-reporter before-build | |
go test -coverprofile c.out -coverpkg ./... ./... -tags=sql | |
./cc-test-reporter format-coverage -o codeclimate.json --prefix $(go list -m) | |
- name: Upload Coverage Result Artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: codeclimate-intg-postgres | |
path: codeclimate.json | |
retention-days: 1 | |
MySQL-8-Integration-Tests: | |
runs-on: ubuntu-latest | |
services: | |
mysql: | |
image: mysql:8 | |
env: | |
MYSQL_ROOT_PASSWORD: safetyculture_exporter | |
MYSQL_DATABASE: safetyculture_exporter_db | |
MYSQL_USER: safetyculture_exporter | |
MYSQL_PASSWORD: safetyculture_exporter | |
options: >- | |
--health-cmd "mysqladmin ping -h localhost" | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
ports: | |
- 3306:3306 | |
steps: | |
- name: Set up Go 1.x | |
uses: actions/setup-go@v2 | |
with: | |
go-version: 1.22.3 | |
- name: Check out code into the Go module directory | |
uses: actions/checkout@v2 | |
- name: Test & Coverage | |
env: | |
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} | |
TEST_DB_DIALECT: mysql | |
TEST_DB_CONN_STRING: "root:safetyculture_exporter@tcp(localhost:3306)/safetyculture_exporter_db?charset=utf8mb4&parseTime=True&loc=Local" | |
run: | | |
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter | |
chmod +x ./cc-test-reporter | |
./cc-test-reporter before-build | |
go test -coverprofile c.out -coverpkg ./... ./... -tags=sql | |
./cc-test-reporter format-coverage -o codeclimate.json --prefix $(go list -m) | |
- name: Upload Coverage Result Artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: codeclimate-mysql-8 | |
path: codeclimate.json | |
retention-days: 1 | |
SQL-Server-Integration-Tests: | |
runs-on: ubuntu-latest | |
services: | |
sqlserver: | |
image: mcr.microsoft.com/mssql/server | |
env: | |
SA_PASSWORD: "SafetyCultureExporter12345" | |
ACCEPT_EULA: "Y" | |
options: >- | |
--health-cmd "/opt/mssql-tools18/bin/sqlcmd -C -S localhost -U sa -P SafetyCultureExporter12345 -Q \"SELECT 1\" || exit 1" | |
--health-interval 10s | |
--health-timeout 10s | |
--health-retries 20 | |
ports: | |
- 1433:1433 | |
steps: | |
- name: Set up Go 1.x | |
uses: actions/setup-go@v2 | |
with: | |
go-version: 1.22.3 | |
- name: Check out code into the Go module directory | |
uses: actions/checkout@v2 | |
- name: Test & Coverage | |
env: | |
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} | |
TEST_DB_DIALECT: sqlserver | |
TEST_DB_CONN_STRING: "sqlserver://sa:SafetyCultureExporter12345@localhost:1433?database=master" | |
run: | | |
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter | |
chmod +x ./cc-test-reporter | |
./cc-test-reporter before-build | |
go test -coverprofile c.out -coverpkg ./... ./... -tags=sql | |
./cc-test-reporter format-coverage -o codeclimate.json --prefix $(go list -m) | |
- name: Upload Coverage Result Artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: codeclimate-intg-sql-server | |
path: codeclimate.json | |
retention-days: 1 | |
Upload-Coverage: | |
runs-on: ubuntu-latest | |
needs: | |
- Unit-Tests | |
- PostgreSQL-Integration-Tests | |
- MySQL-8-Integration-Tests | |
- SQL-Server-Integration-Tests | |
steps: | |
- name: Download all coverage results | |
uses: actions/download-artifact@v4 | |
- name: Upload Coverage to Code Climate | |
env: | |
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} | |
run: | | |
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter | |
chmod +x ./cc-test-reporter | |
./cc-test-reporter sum-coverage */codeclimate.json -p 4 -o codeclimate.total.json | |
./cc-test-reporter upload-coverage -i codeclimate.total.json |