* baldm0mma/ update backend unit tests to run on push to `main` * baldm0mma/ update naming
112 lines
3.6 KiB
YAML
112 lines
3.6 KiB
YAML
name: Backend Unit Tests
|
|
|
|
on:
|
|
pull_request:
|
|
paths-ignore:
|
|
- 'docs/**'
|
|
- '**/*.md'
|
|
push:
|
|
branches:
|
|
- main
|
|
- release-*.*.*
|
|
paths-ignore:
|
|
- 'docs/**'
|
|
- '**/*.md'
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
permissions:
|
|
contents: read
|
|
id-token: write
|
|
|
|
jobs:
|
|
grafana:
|
|
# Run this workflow only for PRs from forks; if it gets merged into `main` or `release-*`,
|
|
# the `pr-backend-unit-tests-enterprise` workflow will run instead
|
|
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == true
|
|
name: Grafana
|
|
runs-on: ubuntu-latest-8-cores
|
|
continue-on-error: true
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
- name: Setup Go
|
|
uses: actions/setup-go@v5
|
|
with:
|
|
go-version-file: go.mod
|
|
- name: Restore GOCACHE
|
|
uses: actions/cache/restore@v4
|
|
with:
|
|
key: go-test-cache-${{ github.ref_name }}
|
|
restore-keys: |
|
|
go-test-cache-${{ github.base_ref }}
|
|
go-test-cache-main
|
|
path: /home/runner/.cache/go-build
|
|
- name: Generate Go code
|
|
run: make gen-go
|
|
- name: Run unit tests
|
|
run: make test-go-unit
|
|
- name: "Generate token"
|
|
id: generate_token
|
|
uses: tibdex/github-app-token@b62528385c34dbc9f38e5f4225ac829252d1ea92
|
|
with:
|
|
app_id: ${{ secrets.GRAFANA_DELIVERY_BOT_APP_ID }}
|
|
private_key: ${{ secrets.GRAFANA_DELIVERY_BOT_APP_PEM }}
|
|
- name: Clear GOCACHE
|
|
run: gh cache delete go-test-cache-${{ github.ref_name }}
|
|
continue-on-error: true
|
|
env:
|
|
GH_TOKEN: ${{ steps.generate_token.outputs.token }}
|
|
- name: Save GOCACHE
|
|
uses: actions/cache/save@v4
|
|
with:
|
|
key: go-test-cache-${{ github.ref_name }}
|
|
path: /home/runner/.cache/go-build
|
|
|
|
grafana-enterprise:
|
|
# Run this workflow for non-PR events (like pushes to `main` or `release-*`) OR for internal PRs (PRs not from forks)
|
|
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork == false
|
|
name: Grafana Enterprise
|
|
runs-on: ubuntu-latest-8-cores
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
- name: Setup Go
|
|
uses: actions/setup-go@v5
|
|
with:
|
|
go-version-file: go.mod
|
|
- name: Restore GOCACHE
|
|
uses: actions/cache/restore@v4
|
|
with:
|
|
key: go-test-cache-${{ github.ref_name }}-enterprise
|
|
restore-keys: |
|
|
go-test-cache-${{ github.base_ref }}-enterprise
|
|
go-test-cache-main-enterprise
|
|
path: /home/runner/.cache/go-build
|
|
- name: Setup Enterprise
|
|
uses: ./.github/actions/setup-enterprise
|
|
with:
|
|
github-app-name: 'grafana-ci-bot'
|
|
- name: Generate Go code
|
|
run: make gen-go
|
|
- name: Run unit tests
|
|
run: make test-go-unit
|
|
- name: "Generate token"
|
|
id: generate_token
|
|
uses: tibdex/github-app-token@b62528385c34dbc9f38e5f4225ac829252d1ea92
|
|
with:
|
|
app_id: ${{ secrets.GRAFANA_DELIVERY_BOT_APP_ID }}
|
|
private_key: ${{ secrets.GRAFANA_DELIVERY_BOT_APP_PEM }}
|
|
- name: Clear GOCACHE
|
|
run: gh cache delete go-test-cache-${{ github.ref_name }}-enterprise
|
|
continue-on-error: true
|
|
env:
|
|
GH_TOKEN: ${{ steps.generate_token.outputs.token }}
|
|
- name: Save GOCACHE
|
|
uses: actions/cache/save@v4
|
|
with:
|
|
key: go-test-cache-${{ github.ref_name }}-enterprise
|
|
path: /home/runner/.cache/go-build
|