Chore: Backend unit test workflow (#101534)
* baldm0mma/ parallelize tests for reporting * baldm0mma/ update combining non-existant outputs * baldm0mma/ remove duplicate logic * baldm0mma/ rem any unnecessary logging * baldm0mma/ add workflow path for test coverage test * baldm0mma/ cache ent * baldm0mma/ update with crucial comments * baldm0mma/ generate go files * baldm0mma/ cache enterprise only once * baldm0mma/ adjust coverage threshholds * baldm0mma/ remove temp artifacts from storage to save $$$ * baldm0mma/ remove strict coverage for unit tests * baldm0mma/ pass coverage go opts * baldm0mma/ update run backend tests action to composite * baldm0mma/ separate make gen go into it's own composite step * baldm0mma/ move options to workflow * baldm0mma/ remove use of action * baldm0mma/ remove unsed action * baldm0mma/ update codeowners * baldm0mma/ add edition logic * baldm0mma/ set env vars in determine-edition action * baldm0mma/ make test * baldm0mma/ debug sequential * baldm0mma/ debugging by removing unit tests * baldm0mma/ TRY SOMETHING DIFFERENT!!! * baldm0mma/ uploading ent from within the workspace * baldm0mma/ revert run-backend-tests action * baldm0mma/ move edition to job level * baldm0mma/ update WIRE_TAGS * baldm0mma/ move the enterprise code to the correct location after extracting it * baldm0mma/ rem packaging/extracting of enterprise code * baldm0mma/ test makefile * baldm0mma/ add ent setup to coverage * baldm0mma/ rem backend test action * baldm0mma/ add wire and go steps to coverage job * baldm0mma/ remove make installation, as it is already present in the "ubuntu-latest" package * baldm0mma/ convert to matrix testing strategy * baldm0mma/ update separate test coverage to only a day * baldm0mma/ add setup-common-backend-testing-env action * baldm0mma/ add setup env * baldm0mma/ update naming * baldm0mma/ updade codeowners * baldm0mma/ rem ent * baldm0mma/ update naming * baldm0mma/ remove multiline syntax in report-coverage * baldm0mma/ make gen-go * baldm0mm/ remove integration tests * baldm0mma/ update coverage params * baldm0mma/ streamline workflow * baldm0mma/ update codeowners * baldm0mma/ update naming * baldm0mma/ simplify logic * baldm0mma/ remove uneeded trigger * baldm0mma/ remove conditional coverage step * baldm0mma/ debug coverage * baldm0mma/ update file name * baldm0mma/ remove artifact upload * baldm0mma/ update atrifact params in the workflow * baldm0mma/ simplify processing logic
This commit is contained in:
@@ -1,60 +0,0 @@
|
||||
name: 'Report Coverage'
|
||||
description: 'Processes and uploads coverage reports from Go tests'
|
||||
|
||||
inputs:
|
||||
unit-cov-path:
|
||||
description: 'Path to unit test coverage file'
|
||||
required: true
|
||||
integration-cov-path:
|
||||
description: 'Path to integration test coverage file'
|
||||
required: true
|
||||
codecov-token:
|
||||
description: 'Token for CodeCov'
|
||||
required: true
|
||||
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- name: Join coverage outputs
|
||||
shell: bash
|
||||
run: |
|
||||
cp ${{ inputs.unit-cov-path }} backend.cov
|
||||
tail -n+2 ${{ inputs.integration-cov-path }} >> backend.cov
|
||||
|
||||
- name: Convert coverage info to per-func stats
|
||||
shell: bash
|
||||
run: go tool cover -func backend.cov > backend-funcs.log
|
||||
|
||||
- name: Convert coverage info to HTML
|
||||
shell: bash
|
||||
run: go tool cover -html backend.cov -o backend.html
|
||||
|
||||
- name: Upload coverage file
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: backend-cov
|
||||
path: |
|
||||
backend.cov
|
||||
backend-funcs.log
|
||||
backend.html
|
||||
retention-days: 30
|
||||
compression-level: 9
|
||||
|
||||
- name: Set summary to total coverage
|
||||
shell: bash
|
||||
run: |
|
||||
echo '# Coverage' >> $GITHUB_STEP_SUMMARY
|
||||
echo '```' >> $GITHUB_STEP_SUMMARY
|
||||
grep 'total:' backend-funcs.log | tr '\t' ' ' >> $GITHUB_STEP_SUMMARY
|
||||
echo '```' >> $GITHUB_STEP_SUMMARY
|
||||
|
||||
- name: Report coverage to CodeCov
|
||||
uses: codecov/codecov-action@v5
|
||||
with:
|
||||
files: backend.cov
|
||||
flags: unified-backend
|
||||
name: backend
|
||||
slug: grafana/grafana
|
||||
# This URL doesn't use the Google auth, but is much more locked down. As such, it requires OIDC or a CodeCov-provided token to do anything.
|
||||
url: https://codecov-webhook.grafana-dev.net
|
||||
token: ${{ inputs.codecov-token }}
|
||||
@@ -1,24 +0,0 @@
|
||||
name: 'Run Backend Tests'
|
||||
description: 'Runs Grafana backend test suites'
|
||||
|
||||
inputs:
|
||||
coverage-opts:
|
||||
description: 'Coverage options to pass to the test command (empty for no coverage)'
|
||||
required: false
|
||||
default: ''
|
||||
test-command:
|
||||
description: 'The test command to run'
|
||||
required: false
|
||||
default: 'make gen-go test-go-unit'
|
||||
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- name: Run tests
|
||||
shell: bash
|
||||
run: |
|
||||
if [ -n "${{ inputs.coverage-opts }}" ]; then
|
||||
COVER_OPTS="${{ inputs.coverage-opts }}" ${{ inputs.test-command }}
|
||||
else
|
||||
${{ inputs.test-command }}
|
||||
fi
|
||||
@@ -1,48 +0,0 @@
|
||||
name: 'Setup Grafana Enterprise'
|
||||
description: 'Clones and sets up Grafana Enterprise repository for testing'
|
||||
|
||||
inputs:
|
||||
github-app-name:
|
||||
description: 'Name of the GitHub App in Vault'
|
||||
required: false
|
||||
default: 'grafana-ci-bot'
|
||||
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- name: Retrieve GitHub App secrets
|
||||
id: get-secrets
|
||||
uses: grafana/shared-workflows/actions/get-vault-secrets@get-vault-secrets-v1.0.1
|
||||
with:
|
||||
repo_secrets: |
|
||||
APP_ID=${{ inputs.github-app-name }}:app-id
|
||||
APP_INSTALLATION_ID=${{ inputs.github-app-name }}:app-installation-id
|
||||
PRIVATE_KEY=${{ inputs.github-app-name }}:private-key
|
||||
|
||||
- name: Generate GitHub App token
|
||||
id: generate_token
|
||||
uses: actions/create-github-app-token@v1
|
||||
with:
|
||||
app-id: ${{ env.APP_ID }}
|
||||
private-key: ${{ env.PRIVATE_KEY }}
|
||||
repositories: "grafana-enterprise"
|
||||
owner: "grafana"
|
||||
|
||||
- name: Setup Enterprise
|
||||
shell: bash
|
||||
env:
|
||||
GH_TOKEN: ${{ steps.generate_token.outputs.token }}
|
||||
run: |
|
||||
git clone https://x-access-token:${GH_TOKEN}@github.com/grafana/grafana-enterprise.git ../grafana-enterprise;
|
||||
|
||||
cd ../grafana-enterprise
|
||||
|
||||
if git checkout ${GITHUB_HEAD_REF}; then
|
||||
echo "checked out ${GITHUB_HEAD_REF}"
|
||||
elif git checkout ${GITHUB_BASE_REF}; then
|
||||
echo "checked out ${GITHUB_BASE_REF}"
|
||||
else
|
||||
git checkout main
|
||||
fi
|
||||
|
||||
./build.sh
|
||||
@@ -0,0 +1,48 @@
|
||||
name: 'Go Coverage Processor'
|
||||
description: 'Process Go test coverage files and generate reports'
|
||||
|
||||
inputs:
|
||||
test-type:
|
||||
description: 'Type of test (e.g., be-unit, be-integration)'
|
||||
required: true
|
||||
type: string
|
||||
coverage-file:
|
||||
description: 'Path to the Go coverage file (.cov)'
|
||||
required: true
|
||||
type: string
|
||||
codecov-token:
|
||||
description: 'Token for CodeCov (required for CodeCov reporting)'
|
||||
required: false
|
||||
default: ''
|
||||
codecov-flag:
|
||||
description: 'Flag to categorize the upload to CodeCov'
|
||||
required: false
|
||||
default: ''
|
||||
codecov-name:
|
||||
description: 'Custom name for the upload to CodeCov'
|
||||
required: false
|
||||
default: ''
|
||||
|
||||
runs:
|
||||
using: 'composite'
|
||||
steps:
|
||||
- name: Process Go coverage output
|
||||
shell: bash
|
||||
run: |
|
||||
# Ensure valid coverage file even if empty
|
||||
if [ ! -s ${{ inputs.coverage-file }} ]; then
|
||||
echo "Coverage file is empty, creating a minimal valid file"
|
||||
echo "mode: set" > ${{ inputs.coverage-file }}
|
||||
fi
|
||||
|
||||
- name: Report coverage to CodeCov
|
||||
uses: codecov/codecov-action@v5
|
||||
if: inputs.codecov-token != ''
|
||||
with:
|
||||
files: ${{ inputs.coverage-file }}
|
||||
flags: ${{ inputs.codecov-flag || inputs.test-type }}
|
||||
name: ${{ inputs.codecov-name || inputs.test-type }}
|
||||
slug: grafana/grafana
|
||||
# This URL doesn't use the Google auth, but is much more locked down. As such, it requires OIDC or a CodeCov-provided token to do anything.
|
||||
url: https://codecov-webhook.grafana-dev.net
|
||||
token: ${{ inputs.codecov-token }}
|
||||
Reference in New Issue
Block a user