Skip to content

Commit

Permalink
BUILD-4976: add pre-commit and renovate (#2)
Browse files Browse the repository at this point in the history
Signed-off-by: Jayadeep Kinavoor Madam <[email protected]>
  • Loading branch information
jayadeep-km-sonarsource authored May 15, 2024
1 parent 48158a4 commit f5e64df
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 2 deletions.
6 changes: 6 additions & 0 deletions .github/renovate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
"github>SonarSource/renovate-config:re-team"
]
}
11 changes: 11 additions & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
on:
pull_request:

jobs:
pre-commit:
name: "pre-commit"
runs-on: ubuntu-latest
steps:
- uses: SonarSource/gh-action_pre-commit@b2e8932c879cc5ad443fc8310b84665fdc6016d5 # 0.0.5
with:
extra-args: --from-ref=origin/${{ github.event.pull_request.base.ref }} --to-ref=${{ github.event.pull_request.head.sha }}
7 changes: 7 additions & 0 deletions .markdownlint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Default state for all rules
default: true

# MD013/line-length - Line length
MD013:
line_length: 120
tables: false
25 changes: 25 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: f71fa2c1f9cf5cb705f73dffe4b21f7c61470ba9 # frozen: v4.4.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 20447075e31543a8b125f2df18d75f3b5e7d4d2e # frozen: 0.22.0
hooks:
- id: check-github-actions
files: .*/action.ya?ml
- id: check-github-workflows
- repo: https://github.com/gruntwork-io/pre-commit
rev: 5341f388c2a962d3bc66e075f00b80ab45b15f24 # v0.1.20
hooks:
- id: shellcheck
- repo: https://github.com/igorshubovych/markdownlint-cli
rev: c9ea83146232fb263effdfe6f222d87f5395b27a # v0.39.0
hooks:
- id: markdownlint
- repo: https://github.com/renovatebot/pre-commit-hooks
rev: 32ee411cf36142e6082f10870ae62172ce9af133 # frozen: 35.32.0
hooks:
- id: renovate-config-validator
23 changes: 21 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,33 @@

Get notified for CircleCI/SonarCloud/SonarQube build failures on Slack.

### Supported platforms
## Supported platforms

Notifications will be triggered upon build failures in any of the following platforms

* SonarCloud
* SonarQube-Next
* CirrusCI

### Enabled branches
## Enabled branches

Slack notifications will be enabled only for builds in the following branches

* master
* main
* dogfood-*
* branch-*

## Requirements

The repository needs to be onboarded to [Vault](https://xtranet-sonarsource.atlassian.net/wiki/spaces/RE/pages/2466316312/HashiCorp+Vault#Onboarding-a-Repository-on-Vault).

### Required permissions

```yaml
development/kv/data/slack
```

## Usage

Create a new GitHub workflow:
Expand Down Expand Up @@ -55,3 +67,10 @@ This project is using [Semantic Versioning](https://semver.org/).
Branches prefixed with a `v` are pointers to the last major versions, ie: [`v1`](https://github.com/SonarSource/gh-action_build-notify/tree/v1).

> Note: the `master` branch is used for development and can not be referenced directly. Use a `v` branch or a tag instead.
## Releases

To create a new release,

1. Draft a new release from Github releases page with the next semantic version.
2. Run `scripts/updatevbranch.sh <tag>` with the release version tag to update the v* branch with the new tag.
16 changes: 16 additions & 0 deletions scripts/updatevbranch.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash
# Update the v* branch to the tag version
# Usage: scripts/updatevbranch.sh <version>
set -xeuo pipefail

version=$1
vbranch="v${version%%.*}"
git fetch --tags --all
git checkout "$vbranch"
git update-ref -m "reset: update branch $vbranch to tag $version" "refs/heads/$vbranch" "$version"
git push --force origin "$vbranch:refs/heads/$vbranch" || (
git show -s --pretty=format:'%h%d' "$vbranch" "origin/$vbranch" "$version"
git log --graph --pretty=format:'%h -%d %s' --abbrev-commit "$vbranch" "origin/${vbranch}" "$version" -20
echo "Push failed, please check the output above" >&2
exit 1
)

0 comments on commit f5e64df

Please sign in to comment.