8000 Add build process using Github Actions by jgebal · Pull Request #1175 · utPLSQL/utPLSQL · GitHub
[go: up one dir, main page]

Skip to content

Add build process using Github Actions #1175

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

Merged
merged 25 commits into from
Jan 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
0354c1a
First attempt at running as github actions
jgebal Nov 24, 2021
de73451
Building github actions
jgebal Nov 24, 2021
1c3004a
Adding OJDBC Download
jgebal Nov 25, 2021
0b9f937
Adding TimeZone
jgebal Nov 25, 2021
0ce0368
Adding 21xe-full
jgebal Nov 25, 2021
4921610
Switching to 21c-xe-slim
jgebal Nov 30, 2021
09d3261
Fixing build numbers and sonar analysis configuration.
jgebal Dec 2, 2021
e3e8c79
Added update of project version and build number.
jgebal Jan 4, 2022
e841b9b
Fixing docs update
jgebal Jan 5, 2022
cae6a35
Update env variables
jgebal Jan 5, 2022
7e87558
Formatting and cleanup
jgebal Jan 5, 2022
9307524
Adding publishing of project version updates
jgebal Jan 5, 2022
169f61c
Update of token
jgebal Jan 6, 2022
82c4d21
Testing publishing of documentation to gh-pages
jgebal Jan 6, 2022
532be8d
Externalizing env variables.
jgebal Jan 6, 2022
12757ea
Added job names.
jgebal Jan 7, 2022
ddd3862
Fixing multi-line if statement.
jgebal Jan 7, 2022
5b64836
Implementing Release Action
jgebal Jan 7, 2022
28cdee3
Refactoring and adding dispatch of other repositories
jgebal Jan 8, 2022
0e6eb70
Testing triggering of build process on other repositories
jgebal Jan 9, 2022
06f3556
8000 Enabling build and slack notification
jgebal Jan 10, 2022
6cd8b16
Update documentation publish condition
jgebal Jan 10, 2022
1fc87de
Enable dependency on downstream job dispatch
jgebal Jan 10, 2022
31cc42d
Final cleanup of travis build leftovers.
jgebal Jan 13, 2022
b94a3f7
Addding `utPLSQL-java-api` repo to dispatch post-build.
jgebal Jan 14, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
.travis.yml export-ignore
mkdocs.yml export-ignore
.travis export-ignore
.github export-ignore
sonar-project.properties export-ignore
tests export-ignore
development export-ignore
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#!/usr/bin/env bash

#When building a new version from a release branch, the version is taken from release branch name
if [[ "${CURRENT_BRANCH}" =~ ^release/v[0-9]+\.[0-9]+\.[0-9]+.*$ ]]; then
version=${CURRENT_BRANCH#release\/}
if [[ "${CI_ACTION_REF_NAME}" =~ ^release/v[0-9]+\.[0-9]+\.[0-9]+.*$ ]]; then
version=${CI_ACTION_REF_NAME#release\/}
else
#Otherwise, version is taken from the VERSION file
version=`cat VERSION`
#When on develop branch, add "-develop" to the version text
if [[ "${CURRENT_BRANCH}" == "develop" ]]; then
if [[ "${CI_ACTION_REF_NAME}" == "develop" ]]; then
version=`sed -E "s/(v?[0-9]+\.[0-9]+\.[0-9]+).*/\1-develop/" <<< "${version}"`
fi
fi
Expand Down
5 changes: 2 additions & 3 deletions .travis/install.sh → .github/scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

set -ev
SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
cd ${SCRIPT_DIR}/../source
cd ${SCRIPT_DIR}/../../source

INSTALL_FILE="install_headless_with_trigger.sql"
if [[ ! -f "${INSTALL_FILE}" ]]; then
Expand All @@ -20,8 +20,7 @@ alter session set plsql_optimize_level=0;
@${INSTALL_FILE} $UT3_DEVELOP_SCHEMA $UT3_DEVELOP_SCHEMA_PASSWORD
SQL

#Run this step only on second child job (12.1 - at it's fastest)
if [[ "${JOB_NUMBER}" =~ \.2$ ]]; then
if [[ "${MATRIX_JOB_ID}" == 1 ]]; then

#check code-style for errors
time "$SQLCLI" $UT3_DEVELOP_SCHEMA/$UT3_DEVELOP_SCHEMA_PASSWORD@//$CONNECTION_STR @../development/utplsql_style_check.sql
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

set -ev
SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
cd ${SCRIPT_DIR}/../${UTPLSQL_DIR}/source
cd ${SCRIPT_DIR}/../../${UTPLSQL_DIR}/source

"$SQLCLI" sys/$ORACLE_PWD@//$CONNECTION_STR AS SYSDBA <<SQL
set serveroutput on
Expand Down
File renamed without changes.
92 changes: 92 additions & 0 deletions .github/scripts/push_docs_to_github_io.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
#!/bin/bash

# Based on `push_docs_to_gh_pages.sh`
# Significant alterations
# - Support for multiple copies of documentation,
# - only clearing out develop
# - index.md logging doc history

# How to run:
# - From repository root .github/scripts/push_docs_to_gh_pages.sh

# Required files / directories (relative from repo root)
# - File: "docs/index.md" with that contains develop docs

# Required ENV Variables
LATEST_DOCS_BRANCH="develop"
GITHUB_IO_REPO='utPLSQL/utPLSQL.github.io'
GITHUB_IO_BRANCH='main'
DOCS_DIR='../../docs/.'

# ENV Variable checks are to help with configuration troubleshooting, they silently exit with unique message.
# Anyone one of them not set can be used to turn off this functionality.

# If a version of the project is not defined
[[ -n "${UTPLSQL_VERSION}" ]] || { echo "variable UTPLSQL_VERSION is not defines or missing value"; exit 1; }
# Fail if the markdown documentation is not present.
[[ -f ./docs/index.md ]] || { echo "file docs/index.md not found"; exit 1; }

# Store latest commit SHA to be used when committing and pushing to github.io repo
SHA=`git rev-parse --verify HEAD`

# clone the repository and switch to GITHUB_IO_BRANCH branch
mkdir pages
cd ./pages
git clone --depth 1 https://${API_TOKEN_GITHUB}@github.com/${GITHUB_IO_REPO} -b ${GITHUB_IO_BRANCH} .

mkdir -p utPLSQL
cd ./utPLSQL
#clear out develop documentation directory and copy docs contents to it.
echo "updating 'develop' documentation directory"
mkdir -p ./develop
rm -rf ./develop/**./* || exit 0
cp -a ${DOCS_DIR} ./develop

# If a Tagged Build then copy to it's own directory as well and to the 'latest' release directory
if [ "${GITHUB_REF_TYPE}" == "tag" ]; then
echo "Creating directory ./${UTPLSQL_VERSION}"
mkdir -p ./${UTPLSQL_VERSION}
rm -rf ./${UTPLSQL_VERSION}/**./* || exit 0
cp -a ${DOCS_DIR} ./${UTPLSQL_VERSION}
echo "Populating 'latest' directory"
mkdir -p ./latest
rm -rf ./latest/**./* || exit 0
cp -a ${DOCS_DIR} ./latest
fi
# Stage changes for commit
git add .

#Check if there are doc changes, if none exit the script
if [[ -z `git diff HEAD --exit-code` ]]; then
echo "No changes to docs detected."
exit 0
fi
#Changes where detected, so we need to update the version log.
now=$(date +"%d %b %Y - %r")
if [ ! -f index.md ]; then
echo "---" >>index.md
echo "layout: default" >>index.md
echo "---" >>index.md
echo "<!-- Auto generated from .github/scripts/push_docs_to_github_io.sh -->" >>index.md
echo "# Documentation versions" >>index.md
echo "" >>index.md
echo "" >>index.md #- 7th line - placeholder for latest release doc
echo "" >>index.md #- 8th line - placeholder for develop branch doc
echo "" >>index.md
echo "## Released Version Doc History" >>index.md
echo "" >>index.md
fi
#If build running on a TAG - it's a new release - need to add it to documentation
if [ "${GITHUB_REF_TYPE}" == "tag" ]; then
sed -i '7s@.*@'" - [Latest ${CI_ACTION_REF_NAME} documentation](latest/) - Created $now"'@' index.md
#add entry to the top of version history (line end of file - ## Released Version Doc History
sed -i '12i'" - [${CI_ACTION_REF_NAME} documentation](${UTPLSQL_VERSION}/) - Created $now" index.md
fi
#replace 4th line in log
sed -i '8s@.*@'" - [Latest development version](develop/) - Created $now"'@' index.md
#Add and Commit the changes back to pages repo.
git add .
git commit -m "Deploy to gh-pages branch: base commit ${SHA}"
# Now that we're all set up, we can push.
git push --quiet origin HEAD:${GITHUB_IO_BRANCH}

12 changes: 12 additions & 0 deletions .github/scripts/push_project_version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash

set -v
echo Current branch is "${CURRENT_BRANCH}"
echo "Committing version & buildNo into branch (${CURRENT_BRANCH})"
git add sonar-project.properties
git add VERSION
git add source/*
git add docs/*
git commit -m 'Updated project version after build [skip ci]'
echo "Pushing to origin"
git push --quiet origin HEAD:${CURRENT_BRANCH}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

set -ev
SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
cd ${SCRIPT_DIR}/../examples
cd ${SCRIPT_DIR}/../../examples

"$SQLCLI" $UT3_DEVELOP_SCHEMA/$UT3_DEVELOP_SCHEMA_PASSWORD@//$CONNECTION_STR <<SQL

Expand Down
10 changes: 10 additions & 0 deletions .github/scripts/set_version_numbers_env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

UTPLSQL_BUILD_NO=$( expr ${GITHUB_RUN_NUMBER} + ${UTPLSQL_BUILD_NO_OFFSET} )
UTPLSQL_VERSION=$(.github/scripts/get_project_version.sh)

echo "UTPLSQL_BUILD_NO=${UTPLSQL_BUILD_NO}" >> $GITHUB_ENV
echo "UTPLSQL_VERSION=${UTPLSQL_VERSION}" >> $GITHUB_ENV
echo UTPLSQL_BUILD_VERSION=$(echo ${UTPLSQL_VERSION} | sed -E "s/(v?[0-9]+\.)([0-9]+\.)([0-9]+)(-.*)?/\1\2\3\.${UTPLSQL_BUILD_NO}\4/") >> $GITHUB_ENV

echo "CURRENT_BRANCH=${CI_ACTION_REF_NAME}" >> $GITHUB_ENV
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

UTPLSQL_VERSION_PATTERN="v?([0-9]+\.){3}[0-9]+[^']*"

echo Current branch is "${CURRENT_BRANCH}"
echo Current branch is "${CI_ACTION_REF_NAME}"

echo Update version in project source files
find ${UTPLSQL_SOURCES_DIR} -type f -name '*' -exec sed -i -r "s/${UTPLSQL_VERSION_PATTERN}/${UTPLSQL_BUILD_VERSION}/" {} \;
find source -type f -name '*' -exec sed -i -r "s/${UTPLSQL_VERSION_PATTERN}/${UTPLSQL_BUILD_VERSION}/" {} \;
echo Source files updated with version tag: ${UTPLSQL_BUILD_VERSION}

echo Update version in documentation files
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#!/usr/bin/env bash

SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"

GL_VALID=1
XSD_DIR="$BUILD_DIR/.travis/xsd"
XML_JAR_DIR="$BUILD_DIR/.travis/lib"
XSD_DIR="${SCRIPT_DIR}/xsd"
XML_JAR_DIR="${SCRIPT_DIR}/lib"
#XML Validator
XML_VALIDATOR="$XML_JAR_DIR/xml_validator.jar"
HTML_VALIDATOR_URL="https://validator.w3.org/nu/"
Expand Down
File renamed without changes.
File renamed without changes.
33 changes: 33 additions & 0 deletions .github/variables/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#utPLSQL install env
UT3_DEVELOP_SCHEMA=UT3_DEVELOP
UT3_DEVELOP_SCHEMA_PASSWORD=ut3
UT3_RELEASE_VERSION_SCHEMA=UT3
UT3_RELEASE_VERSION_SCHEMA_PASSWORD=ut3
UT3_USER='UT3$USER#'
UT3_USER_PASSWORD=ut3
UT3_TESTER=UT3_TESTER
UT3_TESTER_PASSWORD=ut3
UT3_TESTER_HELPER=UT3_TESTER_HELPER
UT3_TESTER_HELPER_PASSWORD=ut3
UT3_TABLESPACE=users

# Database Env
SQLCLI="sqlplus"
OJDBC_HOME=ojdbc
OJDBC_URL="https://download.oracle.com/otn-pub/otn_software/jdbc/213"
ORACLE_PWD="oracle"
TZ="Europe/London"

#Build env
UTPLSQL_CLI_VERSION="3.1.8"
UTPLSQL_DIR="utPLSQL_latest_release"
UTPLSQL_BUILD_NO_OFFSET=3563

#Git configuration
GIT_AUTHOR_NAME="github-actions[bot]"
GIT_AUTHOR_EMAIL="github-actions[bot]@users.noreply.github.com"
GIT_COMMITTER_NAME="github-actions[bot]"
GIT_COMMITTER_EMAIL="github-actions[bot]@users.noreply.github.com"

#Docker environment for running utPLSQL install commands
DOCKER_ENV="-e SQLCLI=sqlplus -e UT3_DEVELOP_SCHEMA -e UT3_DEVELOP_SCHEMA_PASSWORD -e UT3_RELEASE_VERSION_SCHEMA -e UT3_RELEASE_VERSION_SCHEMA_PASSWORD -e UT3_USER -e UT3_USER_PASSWORD -e UT3_TESTER -e UT3_TESTER_PASSWORD -e UT3_TESTER_HELPER -e UT3_TESTER_HELPER_PASSWORD -e UT3_TABLESPACE -e ORACLE_PWD -e CONNECTION_STR -e UTPLSQL_DIR"
Loading
0