Skip to content

Commit

Permalink
First implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastienvermeille committed Aug 18, 2024
1 parent 65d8cf6 commit 579f1c4
Show file tree
Hide file tree
Showing 46 changed files with 3,972 additions and 9 deletions.
598 changes: 598 additions & 0 deletions .code/intellij-java-google-style.xml

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# These are supported funding model platforms

github: [ sebastienvermeille ]
ko_fi: sebastienvermeille
3 changes: 3 additions & 0 deletions .github/autolabeler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
documentation: [ "*.mdx", "*.md", ".doc/*" ]
java: [ "*.java" ]
CI/CD: [ ".github/*" ]
32 changes: 32 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
version: 2
updates:
# Enable version updates for maven
- package-ecosystem: "maven"
directory: "/"
# Check the registry for updates every day (weekdays)
schedule:
interval: "daily"
assignees:
- "sebastienvermeille"
reviewers:
- "sebastienvermeille"
commit-message:
prefix: "[maven] "
labels:
- "java"
- "dependencies"
- "patch"

# Enable version updates for GitHub Actions
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
assignees:
- "sebastienvermeille"
reviewers:
- "sebastienvermeille"
commit-message:
prefix: "[github-action] "
labels:
- "CI/CD"
4 changes: 4 additions & 0 deletions .github/pr-labeler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
feature: [ 'feature/*', 'feat/*' ]
bug: [ 'fix/*', 'bugfix/*', 'issue/*' ]
"CI/CD": [ 'cicd/*' ]
documentation: [ 'doc/*', 'documentation/*' ]
37 changes: 37 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name-template: '$RESOLVED_VERSION'
tag-template: '$RESOLVED_VERSION'
categories:
- title: '🚀 Features'
labels:
- 'new feature'
- 'enhancement'
- title: '🐛 Bug Fixes'
labels:
- 'fix'
- 'bugfix'
- 'bug'
- title: '🧰 Maintenance'
labels:
- 'dependencies'
- 'documentation'
- 'clean code'
- 'CI/CD'
change-template: '- $TITLE @$AUTHOR (#$NUMBER)'
change-title-escapes: '\<*_&' # You can add # and @ to disable mentions, and add ` to disable code blocks.
version-resolver:
major:
labels:
- 'major'
- 'new feature'
minor:
labels:
- 'minor'
patch:
labels:
- 'patch'
- 'dependencies'
default: patch
template: |
## Changelog
$CHANGES
61 changes: 61 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Build
# Ensure that the code compiles and that tests pass
on:
push:
branches:
- master
pull_request:
types: [ opened, synchronize, reopened ]
schedule:
- cron: '0 0 * * *'
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
- name: Check code formatting
run: mvn -B com.spotify.fmt:fmt-maven-plugin:check
- name: Check copyright headers
run: mvn -B license:check
- name: Check dependencies licenses
run: mvn se.ayoy.maven-plugins:ayoy-license-verifier-maven-plugin:verify
- name: Build
run: mvn -B -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn compile
- name: Test
run: mvn -B test -ff
- name: Package
run: mvn -B package -Dmaven.test.skip
- name: Verify
run: mvn -B verify -Dmaven.test.skip
- name: Install
run: mvn -B install -Dmaven.test.skip
- name: Extract PR number
if: github.event_name == 'pull_request'
run: echo ${{ github.event.number }} > PR_NUMBER.txt
- name: Store PR number
if: github.event_name == 'pull_request'
uses: actions/upload-artifact@v4
with:
name: PR_NUMBER
path: PR_NUMBER.txt
retention-days: 1
if-no-files-found: error
- name: Store build files
uses: actions/upload-artifact@v4
with:
name: BUILD_FILES
path: |
stylesniffer-annotation-processor/target
stylesniffer-api/target
stylesniffer-impl/target
stylesniffer-testkit/target
retention-days: 1
if-no-files-found: error
20 changes: 20 additions & 0 deletions .github/workflows/pr-labeler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: PR Labeler
on:
pull_request:
types: [ opened ]

permissions:
contents: read

jobs:
pr-labeler:
name: Automatic PR label suggestion
permissions:
contents: read # for TimonVS/pr-labeler-action to read config file
pull-requests: write # for TimonVS/pr-labeler-action to add labels in PR
runs-on: ubuntu-latest
steps:
- uses: TimonVS/pr-labeler-action@v5
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
configuration-path: .github/pr-labeler.yml # optional, .github/pr-labeler.yml is the default value
42 changes: 42 additions & 0 deletions .github/workflows/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Release Drafter

on:
push:
# branches to consider in the event; optional, defaults to all
branches:
- master
# pull_request event is required only for autolabeler
pull_request:
# Only following types are handled by the action, but one can default to all as well
types: [ opened, reopened, synchronize ]
# pull_request_target event is required for autolabeler to support PRs from forks
# pull_request_target:
# types: [opened, reopened, synchronize]

permissions:
contents: read

jobs:
update_release_draft:
name: Update release draft
permissions:
# write permission is required to create a GitHub release
contents: write
# write permission is required for autolabeler
# otherwise, read permission is required at least
pull-requests: write
runs-on: ubuntu-latest
steps:
# (Optional) GitHub Enterprise requires GHE_HOST variable set
#- name: Set GHE_HOST
# run: |
# echo "GHE_HOST=${GITHUB_SERVER_URL##https:\/\/}" >> $GITHUB_ENV

# Drafts your next Release notes as Pull Requests are merged into "master"
- uses: release-drafter/release-drafter@v6
# (Optional) specify config name to use, relative to .github/. Default: release-drafter.yml
# with:
# config-name: my-config.yml
# disable-autolabeler: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
96 changes: 96 additions & 0 deletions .github/workflows/sonar.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
name: Sonar Analysis
# Perform sonar analysis
# more details here: https://community.sonarsource.com/t/how-to-use-sonarcloud-with-a-forked-repository-on-github/7363/32

on:
workflow_run: # only executed on master branch, prevent leak of SONAR_TOKEN to PRs
workflows: [ Build ]
types: [ completed ]

jobs:
sonar:
name: Sonar
runs-on: ubuntu-latest
if: github.event.workflow_run.conclusion == 'success'
steps:
- name: Download PR number artifact
if: github.event.workflow_run.event == 'pull_request'
uses: dawidd6/action-download-artifact@v6
with:
workflow: Build
run_id: ${{ github.event.workflow_run.id }}
name: PR_NUMBER
- name: Read PR_NUMBER.txt
if: github.event.workflow_run.event == 'pull_request'
id: pr_number
uses: juliangruber/read-file-action@v1
with:
path: ./PR_NUMBER.txt
- name: Request GitHub API for PR data
if: github.event.workflow_run.event == 'pull_request'
uses: octokit/request-action@v2.x
id: get_pr_data
with:
route: GET /repos/{full_name}/pulls/{number}
number: ${{ steps.pr_number.outputs.content }}
full_name: ${{ github.event.repository.full_name }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/checkout@v4
with:
repository: ${{ github.event.workflow_run.head_repository.full_name }}
ref: ${{ github.event.workflow_run.head_branch }}
fetch-depth: 0
- name: Checkout base branch
if: github.event.workflow_run.event == 'pull_request'
run: |
git remote add upstream ${{ github.event.repository.clone_url }}
git fetch upstream
git checkout -B ${{ fromJson(steps.get_pr_data.outputs.data).base.ref }} upstream/${{ fromJson(steps.get_pr_data.outputs.data).base.ref }}
git checkout ${{ github.event.workflow_run.head_branch }}
git clean -ffdx && git reset --hard HEAD
- name: Download build files
if: github.event.workflow_run.event == 'pull_request'
uses: dawidd6/action-download-artifact@v6
with:
workflow: Build
run_id: ${{ github.event.workflow_run.id }}
name: BUILD_FILES
- name: List files
run: ls
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
- name: SonarCloud Scan on PR
if: github.event.workflow_run.event == 'pull_request'
run: |
mvn -B -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn \
-Dsonar.scm.revision=${{ github.event.workflow_run.head_sha }} \
-Dsonar.pullrequest.key=${{ fromJson(steps.get_pr_data.outputs.data).number }} \
-Dsonar.pullrequest.branch=${{ fromJson(steps.get_pr_data.outputs.data).head.ref }} \
-Dsonar.pullrequest.base=${{ fromJson(steps.get_pr_data.outputs.data).base.ref }} \
org.sonarsource.scanner.maven:sonar-maven-plugin:sonar
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
- name: Build on push for sonarscan (not PR branch)
if: github.event.workflow_run.event == 'push' && github.event.workflow_run.head_repository.full_name == github.event.repository.full_name
run: mvn -B -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn verify

- name: SonarCloud Scan on push
if: github.event.workflow_run.event == 'push' && github.event.workflow_run.head_repository.full_name == github.event.repository.full_name
run: |
mvn -B -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn \
-Dsonar.scm.revision=${{ github.event.workflow_run.head_sha }} \
-Dsonar.branch.name=${{ github.event.workflow_run.head_branch }} \
org.sonarsource.scanner.maven:sonar-maven-plugin:sonar
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Loading

0 comments on commit 579f1c4

Please sign in to comment.