Skip to content

Commit 376740a

Browse files
committed
Added Steps Outline
Signed-off-by: Ali <[email protected]>
1 parent 4b24bd6 commit 376740a

File tree

2 files changed

+209
-2
lines changed

2 files changed

+209
-2
lines changed

COBOL Programming Course #4 - Testing/COBOL Programming Course #4 - Testing.md

Lines changed: 209 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,9 +293,216 @@ You can take a look at the COBOL Check wiki page for better understanding: https
293293

294294
## Lab
295295

296-
In this lab exercise, you will learn to set up your environment for the COBOL Check by connecting to an IBM Z system to access the USS(Unix System Services), view a simple COBOL program and test suites in VS Code, compile them on the USS using COBOL Check to generate a copy of the program under test that includes the test cases and paragraphs to be tested. Then you will copy the newly generated program from USS to MVS datasets and submit JCL to compile the copied COBOL program, and view the output. Refer to “Installation of VS Code and extensions” to configure VS Code if you have not already done so. You can either use IBM Z Open Editor and Zowe Explorer, or Code4z.
296+
In this lab exercise, you will learn to set up and automate the COBOL Check environment using GitHub Actions. You'll create a GitHub repository that connects to an IBM Z system, accesses USS (Unix System Services), and automates the process of running COBOL Check on sample programs.
297297

298-
To proceed further, it's better to have some knowledge of JCL and linux terminal commands.
298+
299+
You will:
300+
301+
1. Set up a GitHub repository with necessary workflows and scripts.
302+
303+
2. Use GitHub Actions to automatically upload COBOL Check files to USS.
304+
305+
3. Run COBOL Check on sample programs via automated scripts.
306+
307+
4. Automatically copy generated programs from USS to MVS datasets.
308+
309+
5. Submit JCL to compile the copied COBOL programs and view the output using Zowe Explorer in VS Code.
310+
311+
312+
This lab introduces modern DevOps practices to mainframe development, demonstrating how to integrate traditional COBOL testing with contemporary CI/CD pipelines.
313+
314+
315+
**Prerequisites:**
316+
317+
* GitHub account
318+
319+
* Basic knowledge of Git, GitHub, and GitHub Actions
320+
321+
* VS Code with Zowe Explorer extension installed
322+
323+
* Basic understanding of JCL and Linux terminal commands
324+
325+
326+
Note: While many steps are automated, you'll still interact directly with the mainframe using Zowe Explorer to submit jobs and view results, providing a blend of automated and hands-on experience.
327+
328+
329+
By the end of this lab, you'll have practical experience in setting up an automated testing environment for COBOL programs, bridging the gap between mainframe development and modern DevOps practices.
330+
331+
//
332+
333+
### Set up a GitHub repository with necessary workflows and scripts
334+
1. **Create a new GitHub repository**
335+
- Log into your GitHub account
336+
- Click the '+' icon in the top right corner and select \"New repository\"
337+
- Name your repository (e.g., \"cobol-check-automation\")
338+
- Choose to make it public or private
339+
- Check the box to \"Add a README file\"
340+
- Click \"Create repository\"
341+
342+
2. **Clone the repository locally**
343+
- On the repository page, click the green \"Code\" button\n - Copy the HTTPS URL\n - Open your terminal or command prompt
344+
- Navigate to where you want to store the project
345+
- Run: `git clone <paste-your-repository-url-here>`
346+
- Change into the new directory: `cd cobol-check-automation`
347+
348+
3. **Set up GitHub Secrets**
349+
- In your GitHub repository, go to \"Settings\" > \"Secrets and variables\" > \"Actions\"
350+
- Add two new repository secrets:
351+
- Name: ZOWE_USERNAME, Value: zXXXXX *(for example)*
352+
- Name: ZOWE_PASSWORD, Value: Your IBM Z system password
353+
354+
4. **Create directory structure**
355+
- Create the following directories in your local repository:
356+
```
357+
mkdir -p .github/workflows
358+
mkdir -p .github/scripts\n
359+
mkdir cobol-check
360+
```
361+
362+
5. **Create workflow file**
363+
- Create a new file: `.github/workflows/zowe-cli-operations.yml`
364+
- Copy and paste the following content into this file:
365+
366+
```
367+
name: Zowe CLI Operations
368+
on:
369+
push:
370+
branches: [main]
371+
pull_request:
372+
branches: [main]
373+
jobs:
374+
zowe-operations:
375+
runs-on: ubuntu-latest
376+
377+
steps:
378+
- uses: actions/checkout@v3
379+
380+
- name: Setup Node.js
381+
uses: actions/setup-node@v3
382+
with:
383+
node-version: "18"
384+
385+
- name: Install Zowe CLI
386+
run: npm install -g @zowe/cli@latest
387+
388+
- name: Make scripts executable
389+
run: |
390+
chmod +x .github/scripts/zowe_operations.sh
391+
chmod +x .github/scripts/mainframe_operations.sh
392+
393+
- name: Run Zowe operations
394+
env:
395+
ZOWE_OPT_HOST: 192.86.32.250
396+
ZOWE_OPT_PORT: 10443
397+
ZOWE_OPT_USER: ${{ secrets.ZOWE_USERNAME }}
398+
ZOWE_OPT_PASSWORD: ${{ secrets.ZOWE_PASSWORD }}
399+
ZOWE_OPT_REJECT_UNAUTHORIZED: false
400+
ZOWE_USERNAME: ${{ secrets.ZOWE_USERNAME }}
401+
run: .github/scripts/zowe_operations.sh
402+
403+
- name: Perform mainframe operations
404+
env:
405+
ZOWE_USERNAME: ${{ secrets.ZOWE_USERNAME }}
406+
ZOWE_PASSWORD: ${{ secrets.ZOWE_PASSWORD }}
407+
run: |
408+
sshpass -p "$ZOWE_PASSWORD" ssh -o StrictHostKeyChecking=no [email protected] 'sh -s' < .github/scripts/mainframe_operations.sh
409+
```
410+
411+
6. **Create script files**
412+
- Create `.github/scripts/zowe_operations.sh` and add the following:
413+
414+
```
415+
#!/bin/bash
416+
# zowe_operations.sh
417+
418+
# Convert username to lowercase
419+
LOWERCASE_USERNAME=$(echo "$ZOWE_USERNAME" | tr '[:upper:]' '[:lower:]')
420+
421+
# Check if directory exists, create if it doesn't
422+
if ! zowe zos-files list uss-files "/z/$LOWERCASE_USERNAME/cobolcheck" &>/dev/null; then
423+
echo "Directory does not exist. Creating it..."
424+
zowe zos-files create uss-directory /z/$LOWERCASE_USERNAME/cobolcheck
425+
else
426+
echo "Directory already exists."
427+
fi
428+
429+
# Upload files
430+
zowe zos-files upload dir-to-uss "./cobol-check" "/z/$LOWERCASE_USERNAME/cobolcheck" --recursive --binary-files "cobol-check-0.2.9.jar"
431+
432+
# Verify upload
433+
echo "Verifying upload:"
434+
zowe zos-files list uss-files "/z/$LOWERCASE_USERNAME/cobolcheck"
435+
436+
```
437+
- Create `.github/scripts/mainframe_operations.sh` and add the following:
438+
439+
```
440+
#!/bin/bash
441+
# mainframe_operations.sh
442+
443+
# Set up environment
444+
export PATH=$PATH:/usr/lpp/java/J8.0_64/bin
445+
export JAVA_HOME=/usr/lpp/java/J8.0_64
446+
export PATH=$PATH:/usr/lpp/zowe/cli/node/bin
447+
448+
# Check Java availability
449+
java -version
450+
451+
# Change to the appropriate directory
452+
cd /z/$ZOWE_USERNAME/cobolcheck
453+
ls -al
454+
chmod +x cobolcheck
455+
ls -al
456+
cd scripts
457+
ls -al
458+
chmod +x linux_gnucobol_run_tests
459+
cd ..
460+
pwd
461+
462+
# Run COBOL check on NUMBERS
463+
./cobolcheck -p NUMBERS
464+
465+
# Copy NUMBERS files to datasets
466+
cp CC##99.CBL "//'${ZOWE_USERNAME}.CBL(NUMBERS)'"
467+
cp NUMBERS.JCL "//'${ZOWE_USERNAME}.JCL(NUMBERS)'"
468+
469+
# Run COBOL check on EMPPAY
470+
./cobolcheck -p EMPPAY
471+
472+
# Copy EMPPAY files to datasets
473+
cp CC##99.CBL "//'${ZOWE_USERNAME}.CBL(EMPPAY)'"
474+
cp EMPPAY.JCL "//'${ZOWE_USERNAME}.JCL(EMPPAY)'"
475+
476+
# Run COBOL check on DEPTPAY
477+
./cobolcheck -p DEPTPAY
478+
479+
# Copy DEPTPAY files to datasets
480+
cp CC##99.CBL "//'${ZOWE_USERNAME}.CBL(DEPTPAY)'"
481+
cp DEPTPAY.JCL "//'${ZOWE_USERNAME}.JCL(DEPTPAY)'"
482+
483+
echo "Mainframe operations completed"
484+
485+
```
486+
- Ensure both scripts have Unix-style line endings (LF, not CRLF)
487+
488+
7. **Add COBOL Check files**
489+
- Download the latest COBOL Check distribution from the official repository
490+
- Extract the contents into your `cobol-check` directory
491+
492+
8. **Commit and push your changes**
493+
- Stage your new files: `git add .`
494+
- Commit the changes: `git commit -m \"Initial setup for COBOL Check automation\"`
495+
- Push to GitHub: `git push origin main`
496+
497+
9. **Verify workflow**
498+
- Go to the \"Actions\" tab in your GitHub repository
499+
- You should see the workflow running (triggered by your push)
500+
- Wait for it to complete and check the logs for any errors
501+
502+
503+
By following these steps, you'll have set up a GitHub repository with the necessary workflow and scripts to automate COBOL Check operations. This setup forms the foundation for the rest of the lab exercises, where you'll use this automation to interact with the mainframe and run COBOL Check on your programs."
504+
505+
//
299506
300507
1. Get the latest COBOL Check distribution from the GitHub repository of the COBOL Check https://github.com/openmainframeproject/cobol-check/tree/Developer/build/distributions.
301508
Click on the “View raw” button or the download button on the right most corner. You will get the .zip of COBOL Check.
-187 KB
Loading

0 commit comments

Comments
 (0)