Skip to content

Commit

Permalink
Merge pull request #647 from antip00/master
Browse files Browse the repository at this point in the history
Adding code coverage reports. [WIP]
  • Loading branch information
Slach authored Oct 31, 2024
2 parents 4db3d94 + 53ad2be commit 65a8623
Show file tree
Hide file tree
Showing 16 changed files with 1,590 additions and 153 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
instrumented/*
31 changes: 26 additions & 5 deletions .github/workflows/testflows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@ on:
- main

env:
artifact_paths: |
./Reports/*
./Assets/*
testflows_logs: |
./testflows_logs/*
code_coverage: |
./code_coverage/*
selenium_logs: |
./selenium_logs/*
jobs:
tests:
Expand All @@ -39,12 +42,30 @@ jobs:
--log raw.log
-o classic

- name: Create code coverage for backend
run: docker compose run --rm backend_coverage_generate

- name: Create code coverage for frontend
run: docker compose run --rm frontend_coverage_generate

- name: Create reports
if: always()
run: tests/testflows/infra/create-report.sh

- uses: actions/upload-artifact@v4
if: always()
with:
name: tests-logs
path: ${{ env.artifact_paths}}
name: testflows-logs
path: ${{ env.testflows_logs}}

- uses: actions/upload-artifact@v4
if: always()
with:
name: code-coverage
path: ${{ env.code_coverage}}

- uses: actions/upload-artifact@v4
if: always()
with:
name: selenium-logs
path: ${{ env.selenium_logs}}
17 changes: 17 additions & 0 deletions .nycrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"_comment": "this is file for create instrumented version of module.js to allow get coverage",
"extends": "@istanbuljs/nyc-config-typescript",
"all": true,
"extension": [".ts", ".tsx"],
"report-dir": "api_coverage",
"reporter": [
"html",
"lcov",
"text",
"text-summary"
],
"include": ["src/**/*.ts", "src/**/*.tsx"],
"exclude": [
"src/**/*jest.*"
]
}
69 changes: 69 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ services:

grafana:
image: ${GRAFANA_IMAGE:-grafana/grafana}:${GRAFANA_VERSION:-latest}
user: root
build:
context: ./.config
args:
Expand All @@ -58,10 +59,12 @@ services:
- ./docker/grafana/provisioning/:/etc/grafana/provisioning/
- ./docker/grafana/dashboards/:/var/lib/grafana/dashboards/
- ./docker/grafana/alerting/:/etc/grafana/provisioning/alerting/
- ./coverage/raw/:/usr/share/grafana/coverage

environment:
GF_INSTALL_PLUGINS: grafana-piechart-panel,grafana-worldmap-panel,grafana-clickhouse-datasource
GF_LOG_LEVEL: debug
GOCOVERDIR: "/usr/share/grafana/coverage"
GF_DATABASE_WAL: "true"
GF_UNIFIED_ALERTING_ENABLED: ${GF_UNIFIED_ALERTING_ENABLED:-true}
GF_ALERTING_ENABLED: ${GF_ALERTING_ENABLED:-false}
Expand All @@ -75,6 +78,7 @@ services:
grafana_legacy_alerts:
profiles: [test]
image: ${GRAFANA_IMAGE:-grafana/grafana}:${GRAFANA_VERSION:-10.4.3}
user: root
build:
context: ./.config
args:
Expand All @@ -85,10 +89,12 @@ services:
- ./docker/grafana/provisioning/:/etc/grafana/provisioning/
- ./docker/grafana/dashboards/:/var/lib/grafana/dashboards/
- ./docker/grafana/alerting/:/etc/grafana/provisioning/alerting/
- ./coverage/raw/:/usr/share/grafana/coverage

environment:
GF_INSTALL_PLUGINS: grafana-piechart-panel,grafana-worldmap-panel,grafana-clickhouse-datasource
GF_LOG_LEVEL: debug
GOCOVERDIR: "/usr/share/grafana/coverage"
GF_DATABASE_WAL: "true"
GF_UNIFIED_ALERTING_ENABLED: ${GF_UNIFIED_ALERTING_ENABLED:-false}
GF_ALERTING_ENABLED: ${GF_ALERTING_ENABLED:-true}
Expand Down Expand Up @@ -125,6 +131,7 @@ services:
depends_on:
- clickhouse


frontend_builder:
image: node:lts
working_dir: /grafana-clickhouse
Expand Down Expand Up @@ -159,6 +166,68 @@ services:
chmod +x ./dist/altinity-clickhouse-plugin*
"
frontend_coverage_builder:
image: node:lts
working_dir: /grafana-clickhouse
volumes:
- ./:/grafana-clickhouse
# for speedup npm install under WSL
- "node_modules:/grafana-clickhouse/node_modules"
command: |
bash -xec '
if [[ "3" == `ls -la ./node_modules/ | wc -l` ]]; then npm install; fi && \
mkdir -p instrumented &&
npm run create_instrumented &&
cp -R -n src/* instrumented/ &&
npm run build:test
'
frontend_coverage_generate:
image: node:lts
working_dir: /grafana-clickhouse
volumes:
- ./:/grafana-clickhouse
# for speedup npm install under WSL
- "node_modules:/grafana-clickhouse/node_modules"
command: |
bash -xec '
if [[ "3" == `ls -la ./node_modules/ | wc -l` ]]; then npm install; fi && \
mkdir -p .nyc_output &&
cp tests/testflows/coverage/raw/* .nyc_output/
npx nyc report --reporter=html --report-dir=./tests/testflows/coverage
'
backend_coverage_builder:
image: golang:1.23
working_dir: /go/src/grafana-clickhouse
environment:
GOCACHE: "/go-cache"
RUN_TESTS: "${RUN_TESTS:-.+}"
CGO_ENABLED: "0"
volumes:
- ./:/go/src/grafana-clickhouse
- ./.go-cache:/go/pkg/mod
- ./.go-cache:/go-cache
command: |
bash -xec "
git config --global --add safe.directory /go/src/grafana-clickhouse &&
(command -v mage || go install -v github.com/magefile/mage@latest) &&
GOOS=linux GOARCH=amd64 go build -cover -buildvcs=false -o ./dist/altinity-clickhouse-plugin_linux_amd64 ./pkg/ &&
chmod +x dist/altinity-clickhouse-plugin*
"
backend_coverage_generate:
image: golang:1.23
working_dir: /go/src/grafana-clickhouse
volumes:
- ./:/go/src/grafana-clickhouse
command: |
bash -xec "
go tool covdata textfmt -i=coverage/raw -o=coverage/coverage.txt &&
go tool cover -html=coverage/coverage.txt -o=coverage/coverage.html
"
plugin_signer:
image: node:lts
working_dir: /grafana-clickhouse
Expand Down
Loading

0 comments on commit 65a8623

Please sign in to comment.