Skip to content

Commit

Permalink
Merge pull request #4138 from zowe/user/markackert/holddata-automation
Browse files Browse the repository at this point in the history
draft holddata workflow
  • Loading branch information
MarkAckert authored Jan 29, 2025
2 parents 2b50022 + 3dee4eb commit f605515
Show file tree
Hide file tree
Showing 5 changed files with 401 additions and 0 deletions.
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

0 comments on commit f605515

Please sign in to comment.