Skip to content

Hackaton for release toolkit #984

Hackaton for release toolkit

Hackaton for release toolkit #984

Workflow file for this run

name: Push/PR pipeline
on:
pull_request:
jobs:
rebase:
name: Branch needs rebase
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
# This job might fail for PRs with more than 50 commits. I take that as a feature.
fetch-depth: 50
- name: Check if PR is up to date with target branch
run: |
main=origin/${{ github.base_ref }}
git fetch origin ${{ github.base_ref }}
echo "Getting current HEAD"
target_head=$(git show-ref -s $main)
echo "Getting $main"
merge_base=$(git merge-base HEAD $main)
echo "Checking if current branch is up to date"
if [[ ${target_head} != ${merge_base} ]]; then
echo "Branch ${{ github.head_ref }} is not up to date with $main (${merge_base} != ${target_head}), please rebase"
exit 1
fi
echo "${target_head} = ${merge_base}"
exit 0
go-test:
name: Run tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: "go.mod"
- name: Run tests
# CLI autodetects whether it is running on GHA or not. If we let GHA set this to true, as it normally does,
# tests cases where GITHUB_ACTIONS is expected to be unset would fail.
run: GITHUB_ACTIONS=false go test -race ./...
check-changelog:
name: Check changelog
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check if CHANGELOG is valid
uses: ./validate-markdown
- name: Generate YAML for the changelog
uses: ./generate-yaml
- name: Check if the release is not needed
id: empty
uses: ./is-empty
- run: |
if [[ "${{ steps.empty.outputs.is-empty }}" == "true" ]]; then
echo "Release is empty, failing" >&2
exit 1
fi
static-analysis:
name: Static analysis and linting
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: "go.mod"
- uses: newrelic/newrelic-infra-checkers@v1
with:
# Use full list of linters, rather than the (default) limited set.
golangci-lint-config: golangci-lint
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
continue-on-error: ${{ github.event_name != 'pull_request' }}
with:
# to remove findings from commit history
skip-cache: true
codespell:
name: Codespell
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v4
- name: Codespell test
uses: codespell-project/actions-codespell@master
with:
ignore_words_file: ./.codespellignore
skip: go.mod,go.sum