Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

draft holddata workflow #4138

Open
wants to merge 10 commits into
base: v3.x/staging
Choose a base branch
from
253 changes: 253 additions & 0 deletions .github/scripts/holddata_verification/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions .github/scripts/holddata_verification/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "holddata_verification",
"version": "1.0.0",
"description": "Script to verify Zowe HOLDDATA syntax",
"main": "validate_holddata.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "EPL-2.0",
"dependencies": {
"@actions/core": "1.10.1",
"@actions/github": "6.0.0"
}
}
64 changes: 64 additions & 0 deletions .github/scripts/holddata_verification/validate_holddata.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@



const core = require('@actions/core');

if (process.env['HOLDDATA_FILES'] == null ||
process.env['HOLDDATA_FILES'].trim().length == 0) {
core.setFailed('This script requires the HOLDDATA_FILES env to be set.');
return;
}

core.info(`Checking HOLDDATA: ${process.env.HOLDDATA_FILES}`);

const errors = [];
for (const holdDataFile of process.env.HOLDDATA_FILES.trim().split(' ')) {

const fs = require('fs');

core.info(`Testing ${holdDataFile}`);
const lines = fs.readFileSync(holdDataFile, 'utf-8').split('\n');

const openParens = [];

for (let i = 0; i < lines.length; i++) {

const rawLine = lines[i];
const line = lines[i].trim();

if (rawLine.length > 64) {
errors.push({file: holdDataFile, error: `Line ${i+1} is too long. It has ${line.length} characters, but should have no more than 64.` });
}

if (line.startsWith('*')) {
continue;
}
if (line.includes('/*') || line.includes('*/')) {
errors.push({file: holdDataFile, error: `HOLDDATA has the invalid comment sequence on line ${i+1}. Either '/*' or '*/'`});
}
if (line.includes('~')) {
errors.push({file: holdDataFile, error: `HOLDDATA has the invalid character '~' on line ${i+1}. This character is reserved by automation for use in sed and should not be used.`});
}
for (let j = 0; j < line.length; j++) {
if (line.charAt(j) === '(') {
openParens.push(j);
}
if (line.charAt(j) === ')') {
if (openParens.pop() == null) {
errors.push({file: holdDataFile, error: `HOLDDATA has a ')' without a matching '(' on line ${i+1}.`});
}
}
}
}

if (openParens.length > 0) {
errors.push({file: holdDataFile, error: `HOLDDATA has a '(' without a matching ')'.`});
}
}

if (errors.length > 0) {
core.error(JSON.stringify(errors));
core.setFailed(`HOLDDATA has errors. See above.`);
} else {
core.info(`HOLDDATA has no errors.`);
}
63 changes: 63 additions & 0 deletions .github/workflows/holddata-warn.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Discover HOLDDATA

permissions: read-all

on:
pull_request:
types: [opened, synchronize]
branches:
- v3.x/staging
- v3.x/rc
- v2.x/staging
- v2.x/rc

jobs:
check-holddata:
runs-on: ubuntu-latest
steps:

- name: Checkout code
uses: actions/checkout@v4

- name: Install Dependencies for verification script
run: npm install
working-directory: .github/scripts/holddata_verification

- name: List changed files which are candidates for HOLDDATA
id: changed-files-yaml
uses: tj-actions/changed-files@v45
with:
files_yaml: |
hold:
- smpe/bld/service/current-hold-*.txt
src:
- example-zowe.yaml
- files/defaults.yaml
- files/sca/zowe_base_sca.json
- files/SZWEEXEC/**
- files/SZWESAMP/**
- schemas/**
- smpe/bld/SMPMCS.txt
- workflows/files/ZWEKRIN*
- workflows/templates/ZWESECU*

# If there's a change to SAMP or EXEC files and no matching holddata, fail workflow.
# We can't know if there must be HOLDDATA in this case, so this WF can never be a required check.
- name: Check for changed files without matching holddata
if: ${{ steps.changed-files-yaml.outputs.src_any_changed == 'true' && steps.changed-files-yaml.outputs.hold_any_changed == 'false' }}
env:
TEST_ALL_CHANGED_FILES: ${{ steps.changed-files-yaml.outputs.src_all_changed_files }}
run: |
echo "One or more SAMP or EXEC file(s) have changed."
echo "This may require HOLDDATA to be created."
echo "Files changed: $TEST_ALL_CHANGED_FILES"
exit 1

- name: Check HOLDDATA is in a valid format
if: ${{ steps.changed-files-yaml.outputs.hold_any_changed == 'true' }}
env:
HOLDDATA_FILES: ${{ steps.changed-files-yaml.outputs.hold_all_changed_files }}
id: verify-holddata-format
run: node .github/scripts/holddata_verification/validate_holddata.js


Loading
Loading