Skip to content

Commit

Permalink
Implement Format Checks for Groovy Code in GitHub Actions Workflow
Browse files Browse the repository at this point in the history
Signed-off-by: karim mdmirajul <[email protected]>
  • Loading branch information
karim20230 committed May 21, 2024
1 parent 3ef5f80 commit 3799e0d
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/format-checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# SPDX-FileCopyrightText: 2022-2024 TII (SSRC) and the Ghaf contributors
# SPDX-License-Identifier: Apache-2.0

name: Format-checks

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
groovy-lint:
runs-on: ubuntu-22.04
steps:
- name: Check out code
uses: actions/checkout@v2

- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '14'

- name: Set up Java
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: '17'

- name: Install GroovyLint
run: npm install -g npm-groovy-lint

- name: Run GroovyLint
run: npm-groovy-lint -p "**/*.groovy" --failon error --verbose
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,20 @@ SPDX-License-Identifier: CC-BY-SA-4.0

# ghaf-jenkins-pipeline
This repository stores the [Ghaf](https://github.com/tiiuae/ghaf) Jenkins pipeline script, which will be used from [ghaf-infra](https://github.com/tiiuae/ghaf-infra). Eventually, we might want to move the pipeline script from this repo to [Ghaf](https://github.com/tiiuae/ghaf) repo. However, while we are still developing the pipeline, we expect frequent (possibly major) changes to the Jenkins setup which is why we don't want to push these changes through [Ghaf](https://github.com/tiiuae/ghaf) yet.

# Format-checks GroovyLint GitHub Action

The GitHub Action is designed to maintain the quality of Groovy code in our ghaf-jenkins-pipeline repository.

## Workflow Steps

1. **Check out code**: This step checks out our repository's code onto the runner, allowing the workflow to access it.

2. **Set up Node.js**: This step sets up a specific version of Node.js on the runner, in this case, version 14.

3. **Install GroovyLint**: This step installs GroovyLint, a linter for Groovy code, globally using npm.

4. **Run GroovyLint**: This step runs GroovyLint on all `.groovy` files in our repository. If GroovyLint finds any errors, the command will exit with a non-zero status code, causing the GitHub Actions workflow to fail.

## NOTE :
It automatically checks the formatting of the Groovy code whenever a push is made to our ghaf-jenkins-pipeline `main` branch or a pull request is opened against it.

0 comments on commit 3799e0d

Please sign in to comment.