Add load utils.groovy existence in pipelines #228
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# SPDX-FileCopyrightText: 2022-2024 TII (SSRC) and the Ghaf contributors | |
# SPDX-License-Identifier: Apache-2.0 | |
name: Format-checks | |
# This workflow gets triggered on push or pull request events to the main branch | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
jobs: | |
groovy-lint: | |
# This job runs on an Ubuntu 22.04 runner | |
runs-on: ubuntu-22.04 | |
steps: | |
# Checks-out our repository under $GITHUB_WORKSPACE | |
- uses: actions/checkout@v3 | |
# Sets up a Node.js environment with the specified version | |
- name: Set up Node.js environment | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '20.13.1' | |
- name: Install npm-groovy-lint | |
run: npm install -g [email protected] | |
- name: Fail if there are any errors | |
run: npm-groovy-lint --failon error . | |
# Custom step to check for missing 'load "utils.groovy"' in specified files | |
- name: Check for missing imports | |
run: | | |
missing_import_files=$(grep -L 'load "utils.groovy"' \ | |
fmo-os-main-pipeline.groovy \ | |
ghaf-main-pipeline.groovy \ | |
ghaf-nightly-pipeline.groovy \ | |
ghaf-parallel-pipeline.groovy \ | |
ghaf-pre-merge-pipeline.groovy \ | |
ghaf-release-pipeline.groovy) | |
if [ -n "$missing_import_files" ]; then | |
echo "Error: The following files are missing 'load \"utils.groovy\"':" | |
echo "$missing_import_files" | |
exit 1 | |
else | |
echo "All specified files contain 'load \"utils.groovy\"'." | |
fi |