Skip to content

Commit

Permalink
Automated GitHub build restructure (z390development#519)
Browse files Browse the repository at this point in the history
Restructure build jobs
  • Loading branch information
adelosa authored Nov 22, 2023
1 parent 316d8a0 commit f1c6830
Show file tree
Hide file tree
Showing 13 changed files with 144 additions and 141 deletions.
17 changes: 0 additions & 17 deletions .github/actions/build/Dockerfile

This file was deleted.

9 changes: 0 additions & 9 deletions .github/actions/build/action.yml

This file was deleted.

4 changes: 0 additions & 4 deletions .github/actions/build/entrypoint.sh

This file was deleted.

6 changes: 0 additions & 6 deletions .github/actions/build/requirements.txt

This file was deleted.

106 changes: 82 additions & 24 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,95 @@ name: Build z390
on: [push]

jobs:
build:

build-distribution:
runs-on: ubuntu-latest
outputs:
VERSION: ${{ steps.version.outputs.VERSION }}
steps:
- name: Checkout main
uses: actions/checkout@v1
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: version
run: echo "version=$(git describe)" >> $GITHUB_OUTPUT
run: |
VERSION=$(git describe --tags)
echo "VERSION=${VERSION}" >> $GITHUB_OUTPUT
id: version
- name: Build z390
uses: ./.github/actions/build
- name: release
uses: actions/create-release@v1
if: startsWith(github.ref, 'refs/tags/v')
shell: bash
- uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '8'
- name: Build z390 distribution
run: bash/blddist
- name: Save the distribution
uses: actions/upload-artifact@v3
with:
name: dist
path: ./dist/z390_${{ steps.version.outputs.VERSION }}.zip

run-tests:
runs-on: ubuntu-latest
needs: build-distribution
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '8'
- name: get dist artefact
uses: actions/download-artifact@v3
with:
name: dist
- name: Install dist and run tests
run: |
mkdir -p dist
unzip z390_${VERSION}.zip -d dist
ls -l dist/z390_${VERSION}
cp dist/z390_${VERSION}/z390.jar .
Z390_PROJECT_ROOT="../dist/z390_${VERSION}" z390test/gradlew -p z390test test
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
id: create_release
with:
draft: false
prerelease: false
release_name: ${{ steps.version.outputs.version }}
tag_name: ${{ github.ref }}
body_path: release.md
- name: upload dist artifact
uses: actions/upload-release-asset@v1
if: startsWith(github.ref, 'refs/tags/v')
VERSION: ${{ needs.build-distribution.outputs.VERSION }}

run-windows-demo:
runs-on: windows-latest
needs:
- build-distribution
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '8'
- name: get dist artefact
uses: actions/download-artifact@v3
with:
name: dist
- name: Install dist and run demos
shell: cmd
run: |
tar -xf z390_%VERSION%.zip
dir z390_%VERSION%
z390_%VERSION%\bat\RUNASMDEMOS.BAT
z390_%VERSION%\bat\RUNCBLDEMOS.BAT
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VERSION: ${{ needs.build-distribution.outputs.VERSION }}

create-release:
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
needs:
- build-distribution
- run-tests
- run-windows-demo
steps:
- name: get dist artefact
uses: actions/download-artifact@v3
with:
name: dist
- name: release
uses: softprops/action-gh-release@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./dist/z390_${{ steps.version.outputs.version }}.zip
asset_name: z390_${{ steps.version.outputs.version }}.zip
asset_content_type: application/zip
files: |
z390_${{ needs.build-distribution.outputs.VERSION }}.zip
14 changes: 0 additions & 14 deletions .github/workflows/buildwin.yml

This file was deleted.

14 changes: 9 additions & 5 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
name: Publish docs via GitHub Pages
on: [push]
on:
push:
branches:
- main
- doc/**

jobs:
deploy:
name: Deploy docs
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
fetch-depth: 0
lfs: true
- name: version
run: echo "version=$(git describe)" >> $GITHUB_OUTPUT
run: echo "version=$(git describe --tags)" >> $GITHUB_OUTPUT
id: version
- uses: actions/setup-python@v2
- uses: actions/setup-python@v4
with:
python-version: 3.8
python-version: 3.11
- run: pip install -r doc/requirements.txt
- run: mkdocs gh-deploy --force
env:
Expand Down
82 changes: 39 additions & 43 deletions bash/blddist
Original file line number Diff line number Diff line change
Expand Up @@ -7,71 +7,67 @@ set -e # exit on all errors
cd $(dirname $0) # set to directory of script
cd .. # cd back to root

root_dir=$(pwd)
version_tag=$(git describe)
dist_folder=dist
ROOT_DIR=$(pwd)
VERSION="$(git describe --tags)"
echo "Building z390 ${VERSION}"
DIST_DIR=dist

if [ "$1" == "clean" ]; # if "clean" parm passed
then
git clean -dfX # delete all git ignored files
git clean -dfX # delete all git ignored files
fi

# do the jar build
bash/bldjar # create the z390 jar
# build jar
bash/bldjar # create the z390 jar

# Create pdf doc - available in <root>/site/pdf/z390.pdf
if [ -d "/opt/docenv" ]
then
# the GitHub docker image has the python virtenv prebuilt at this location
source /opt/docenv/bin/activate
else
# otherwise create the environment
rm -rf docenv/
python -m venv docenv
source docenv/bin/activate
pip install wheel
pip install -r doc/requirements.txt
fi
ENABLE_PDF_EXPORT=1 Z390_VERSION=${version_tag} mkdocs build
# build standard libraries
bash/bldlib # build standard libs
bash/bldcbllib # build cobol libs

# Create/clean build folder
mkdir -p ${dist_folder} # create dist folder if does not exist
echo "/**" > ${dist_folder}/.gitignore # ignore the dist folder
rm -rf ${dist_folder}/z390_${version_tag} # delete version dist directory
rm -f ${dist_folder}/z390_${version_tag}.zip # delete the zip
# Create/clean dist folder
mkdir -p ${DIST_DIR} # create dist folder if does not exist
echo "/**" > ${DIST_DIR}/.gitignore # ignore the dist folder
rm -rf ${DIST_DIR}/z390_${VERSION} # delete version dist directory
rm -f ${DIST_DIR}/z390_${VERSION}.zip # delete the zip

bash/bldjar # create the z390 jar
bash/bldzstrmac 'build/zstrmac' # generate HLASM compatible SPM's
# build javadocs
bash/bldjavadoc 'build/javadoc' # docs in build/javadocs

# generate HLASM compatible SPM's
bash/bldzstrmac 'build/zstrmac'

cd ${dist_folder}
mkdir z390_${version_tag}
cd z390_${version_tag}
cd ${DIST_DIR}
mkdir z390_${VERSION}
cd z390_${VERSION}

# add core files to the build dir
cp ${root_dir}/z390.jar . # jar
cp ${root_dir}/site/pdf/z390.pdf . # pdf doc
core_dirs=( bash bat mac zcobol cics linklib README.txt LICENSE )
for dir in ${core_dirs[@]}; do
cp -R ${root_dir}/${dir} . # unix bash scripts
cp ${ROOT_DIR}/z390.jar . # jar
CORE_DIRS=( bash bat mac zcobol cics linklib README.txt LICENSE )
for dir in ${CORE_DIRS[@]}; do
cp -R ${ROOT_DIR}/${dir} .
done

# add test and supplimental components
supp_dirs=( assist demo guam qsam bsam rt soa sort structuredmacros tests vsam1
SUPP_DIRS=( assist demo guam qsam bsam rt soa sort structuredmacros tests vsam1
vsam2 vse zopcheck zpar )
for dir in ${supp_dirs[@]}; do
cp -R ${root_dir}/${dir} . # unix bash scripts
for dir in ${SUPP_DIRS[@]}; do
cp -R ${ROOT_DIR}/${dir} .
done

# add structured programming macros to mac/spm folder
mkdir -p mac/spm
cp -R ${root_dir}/build/zstrmac/* mac/spm
cp -R ${ROOT_DIR}/build/zstrmac/* mac/spm

# add javadoc
mkdir -p javadoc
cp -R ${ROOT_DIR}/build/javadoc/* javadoc

# remove components not required for distribution
del_items=('bash/bldjar' 'bat/BLDJAR.BAT' 'bash/blddist' 'bash/relver' 'bat/RELVER.BAT')
for item in ${del_items[@]}; do
rm ${item} # unix bash scripts
DEL_ITEMS=('bash/bldjar' 'bat/BLDJAR.BAT' 'bash/blddist' 'bash/relver' 'bat/RELVER.BAT')
for item in ${DEL_ITEMS[@]}; do
rm ${item}
done

# create zip package
cd ..
zip -r z390_${version_tag}.zip z390_${version_tag}
zip -q -dd -r z390_${VERSION}.zip z390_${VERSION}
13 changes: 1 addition & 12 deletions bash/bldjar
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,6 @@
set -e # exit on all errors
cd $(dirname $0) # set to directory of script

# if not suppressed ($1 = nodocs), generate javadoc; ignore any errors
case $1 in
[Nn][Oo][Dd][Oo][Cc][Ss])
shift
;;
*)
./bldjavadoc
ec=$?
echo "bldjavadoc return code is $ec"
;;
esac

mkdir -p "../jar" # create directory if it does not exist

# empty destination directory; cd to it
Expand Down Expand Up @@ -47,6 +35,7 @@ ls -l
echo ""
echo "Build is complete."
echo ""

# switch to z390 top level directory
cd ..
cp jar/z390.jar .
Expand Down
14 changes: 8 additions & 6 deletions bash/bldjavadoc
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,18 @@
cd $(dirname $0) # set to directory of script
cd .. # up one to z390 directory

javadocdir=docenv/javadoc # directory for javadoc files

mkdir -p "${javadocdir}" # create directory if it does not exist
DEST=$1
if [ -z "${DEST}" ]; then
DEST="build/javadoc"
fi
mkdir -p "${DEST}" # create directory if it does not exist

# empty destination directory
rm -rf ${javadocdir}/*
rm -rf ${DEST}/*

# build the javadoc
echo "Building javadoc from src/*.java into ${javadocdir} directory ..."
javadoc -d ${javadocdir} src/*.java
echo "Building javadoc from src/*.java into ${DEST} directory ..."
javadoc -quiet -Xdoclint:none -d ${DEST} src/*.java
ec=$?
echo "The exit code of the javadoc command is $ec"
if [ $ec -ne 0 ]; then echo "bldjavadoc Error encountered building javadoc"; fi
Expand Down
2 changes: 1 addition & 1 deletion bash/bldzstrmac
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ if [ -z "${DEST}" ]; then
DEST="build/zstrmac"
fi
mkdir -p "${DEST}" # create folder if does not exist
find build/zstrmac -type f -not -name 'README.md' -delete # clear previous
find "$DEST" -type f -not -name 'README.md' -delete # clear previous

ZSTR="rt/test/ZSTRMAC2.ZSM"

Expand Down
3 changes: 3 additions & 0 deletions z390test/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
### bin folder
bin/

### Idea
.idea

Expand Down
1 change: 1 addition & 0 deletions z390test/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ dependencies {
implementation 'org.junit.jupiter:junit-jupiter:5.8.1'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
}

test {
Expand Down

0 comments on commit f1c6830

Please sign in to comment.