* baldm0mma/ add gha workflow * baldm0mma/ add codeowners * baldm0mma/ update health command * baldm0mma/ update aliases for services * baldm0mma/ rewrite migration attempt * baldm0mma/ fix package names for ubuntu * baldm0mma/ add authentication * baldm0mma/ update auth * baldm0mma/ add debugs * baldm0mma/ add continue on error * baldm0mma/ simplyfy ent fork logic * baldm0mma/ debug fork status * baldm0mma/ add debug workflow for enterprise access * chore: add workflow_dispatch trigger to backend test workflow * baldm0mma/ debug ent run * baldm0mma/ add more robust debugging info * baldm0mma/ use old drone ci app for testing * baldm0mma/ update app name * baldm0mma/ update workflow creds * baldm0mma/ rename * baldm0mma/ update codeownders * baldm0mma/ update paths to ignore paths for docs and markdown files * baldm0mma/ create 'Setup Grafana Enterprise' action and remove from current workflow * baldm0mma/ fail at git clone * baldm0mma/ absract away "Run backend tests" and "Run backend integration tests" into their own actions * baldm0mma/ update directory strcuture to adhere to GHAs best practices * baldm0mma/ remove optional configs * baldm0mma/ update codeowners * baldm0mma/ update gh app name * baldm0mma/ remove circ dep * baldm0mma/ uncomment out enterprise setup for test * baldm0mma/ update valut url * baldm0mma/ use vault instance rather than url * baldm0mma/ debug * baldm0mma/ Removed the multiline string format * baldm0mma/ add installation key * baldm0mma/ update path * baldm0mma/ debug vault access * baldm0mma/ add ent * baldm0mma/ remove debugging * baldm0mma/ update paths * baldm0mma/ update codeowners * baldm0mma/ update paths and codeowners * baldm0mma/ add continue-on-error to assure the workflow isn't blocking * baldm0mma/ simplify test action execution * baldm0mma/ remove wire install step * baldm0mma/ add conditions for coverage output * baldm0mma/ add conditions for coverage output for integration test action * baldm0mma/ add report converage file * baldm0mma/ remove uneeded action * baldm0mma/ update codeowners * baldm0mma/ push small change to go file and add log * baldm0mma/ update trigger conditions * baldm0mma/ update converage conditions * baldm0mma/ update Run backend integration tests with correct action * baldm0mma/ test 2 * baldm0mma/ update with -coverpkg flag * baldm0mma/ remove backend-coverage as it is now redundant * baldm0mma/ update codeowners * baldm0mma/ update test file * baldm0mma/ update coverage logic
107 lines
3.4 KiB
YAML
107 lines
3.4 KiB
YAML
name: Test Backend
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
push:
|
|
branches:
|
|
- main
|
|
paths-ignore:
|
|
- 'docs/**'
|
|
- '**/*.md'
|
|
pull_request:
|
|
paths-ignore:
|
|
- 'docs/**'
|
|
- '**/*.md'
|
|
|
|
permissions:
|
|
contents: read
|
|
id-token: write
|
|
|
|
env:
|
|
EDITION: 'oss'
|
|
|
|
jobs:
|
|
test-backend:
|
|
name: Test Backend
|
|
runs-on: ubuntu-latest
|
|
continue-on-error: true
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Go
|
|
uses: actions/setup-go@v5
|
|
with:
|
|
go-version: '1.23.5'
|
|
cache: true
|
|
|
|
- name: Install dependencies
|
|
run: |
|
|
sudo apt-get update
|
|
sudo apt-get install -y build-essential shared-mime-info make
|
|
|
|
- name: Get runner name
|
|
run: echo ${{ runner.name }}
|
|
|
|
- name: Setup Enterprise (PR only)
|
|
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == false
|
|
uses: ./.github/actions/setup-enterprise
|
|
|
|
- name: Verify CUE generation
|
|
run: CODEGEN_VERIFY=1 make gen-cue
|
|
|
|
- name: Verify Jsonnet generation
|
|
run: CODEGEN_VERIFY=1 make gen-jsonnet
|
|
|
|
- name: Check if coverage should be generated
|
|
id: check-coverage
|
|
env:
|
|
GH_TOKEN: ${{ github.token }}
|
|
run: |
|
|
echo "Event: ${{ github.event_name }}"
|
|
echo "Ref: ${{ github.ref }}"
|
|
|
|
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
|
|
echo "PR changed files:"
|
|
files=$(gh api repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/files --jq '.[].filename')
|
|
echo "$files"
|
|
if echo "$files" | grep -E "(pkg/|go\.)"; then
|
|
echo "Coverage will be generated: true (PR changes)"
|
|
echo "generate=true" >> $GITHUB_OUTPUT
|
|
else
|
|
echo "Coverage will be generated: false"
|
|
echo "generate=false" >> $GITHUB_OUTPUT
|
|
fi
|
|
elif [[ "${{ github.event_name }}" == "push" && "${{ github.ref }}" == "refs/heads/main" ]] && \
|
|
[[ "${{ github.event.head_commit.modified }}" =~ (pkg/|go\.|\.github/workflows/pr-test-backend\.yml) ]]; then
|
|
echo "Coverage will be generated: true (push to main)"
|
|
echo "generate=true" >> $GITHUB_OUTPUT
|
|
else
|
|
echo "Coverage will be generated: false"
|
|
echo "generate=false" >> $GITHUB_OUTPUT
|
|
fi
|
|
|
|
- name: Run backend tests
|
|
uses: ./.github/actions/run-backend-tests
|
|
with:
|
|
coverage-opts: ${{ steps.check-coverage.outputs.generate == 'true' && '-coverprofile=unit.cov -coverpkg=github.com/grafana/grafana/...' || '' }}
|
|
test-command: 'make gen-go test-go-unit'
|
|
|
|
- name: Run backend integration tests
|
|
uses: ./.github/actions/run-backend-tests
|
|
with:
|
|
coverage-opts: ${{ steps.check-coverage.outputs.generate == 'true' && '-coverprofile=integration.cov -coverpkg=github.com/grafana/grafana/...' || '' }}
|
|
test-command: 'make gen-go test-go-integration'
|
|
|
|
- name: Generate Coverage Report
|
|
if: steps.check-coverage.outputs.generate == 'true'
|
|
uses: ./.github/actions/report-coverage
|
|
with:
|
|
unit-cov-path: unit.cov
|
|
integration-cov-path: integration.cov
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
cancel-in-progress: true
|