8000 Merge pull request #1175 from utPLSQL/feature/github_actions · utPLSQL/utPLSQL@327110f · GitHub
[go: up one dir, main page]

Skip to content
8000

Commit 327110f

Browse files
authored
Merge pull request #1175 from utPLSQL/feature/github_actions
Add build process using Github Actions
2 parents a45cc3c + b94a3f7 commit 327110f

32 files changed

+475
-625
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
.travis.yml export-ignore
55
mkdocs.yml export-ignore
66
.travis export-ignore
7+
.github export-ignore
78
sonar-project.properties export-ignore
89
tests export-ignore
910
development export-ignore

.travis/get_project_version.sh renamed to .github/scripts/get_project_version.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
#!/usr/bin/env bash
22

33
#When building a new version from a release branch, the version is taken from release branch name
4-
if [[ "${CURRENT_BRANCH}" =~ ^release/v[0-9]+\.[0-9]+\.[0-9]+.*$ ]]; then
5-
version=${CURRENT_BRANCH#release\/}
4+
if [[ "${CI_ACTION_REF_NAME}" =~ ^release/v[0-9]+\.[0-9]+\.[0-9]+.*$ ]]; then
5+
version=${CI_ACTION_REF_NAME#release\/}
66
else
77
#Otherwise, version is taken from the VERSION file
88
version=`cat VERSION`
99
#When on develop branch, add "-develop" to the version text
10-
if [[ "${CURRENT_BRANCH}" == "develop" ]]; then
10+
if [[ "${CI_ACTION_REF_NAME}" == "develop" ]]; then
1111
version=`sed -E "s/(v?[0-9]+\.[0-9]+\.[0-9]+).*/\1-develop/" <<< "${version}"`
1212
fi
1313
fi

.travis/install.sh renamed to .github/scripts/install.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

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

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

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

2625
#check code-style for errors
2726
time "$SQLCLI" $UT3_DEVELOP_SCHEMA/$UT3_DEVELOP_SCHEMA_PASSWORD@//$CONNECTION_STR @../development/utplsql_style_check.sql

.travis/install_utplsql_release.sh renamed to .github/scripts/install_utplsql_release.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

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

77
"$SQLCLI" sys/$ORACLE_PWD@//$CONNECTION_STR AS SYSDBA <<SQL
88
set serveroutput on
File renamed without changes.
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
#!/bin/bash
2+
3+
# Based on `push_docs_to_gh_pages.sh`
4+
# Significant alterations
5+
# - Support for multiple copies of documentation,
6+
# - only clearing out develop
7+
# - index.md logging doc history
8+
9+
# How to run:
10+
# - From repository root .github/scripts/push_docs_to_gh_pages.sh
11+
12+
# Required files / directories (relative from repo root)
13+
# - File: "docs/index.md" with that contains develop docs
14+
15+
# Required ENV Variables
16+
LATEST_DOCS_BRANCH="develop"
17+
GITHUB_IO_REPO='utPLSQL/utPLSQL.github.io'
18+
GITHUB_IO_BRANCH='main'
19+
DOCS_DIR='../../docs/.'
20+
21+
# ENV Variable checks are to help with configuration troubleshooting, they silently exit with unique message.
22+
# Anyone one of them not set can be used to turn off this functionality.
23+
24+
# If a version of the project is not defined
25+
[[ -n "${UTPLSQL_VERSION}" ]] || { echo "variable UTPLSQL_VERSION is not defines or missing value"; exit 1; }
26+
# Fail if the markdown documentation is not present.
27+
[[ -f ./docs/index.md ]] || { echo "file docs/index.md not found"; exit 1; }
28+
29+
# Store latest commit SHA to be used when committing and pushing to github.io repo
30+
SHA=`git rev-parse --verify HEAD`
31+
32+
# clone the repository and switch to GITHUB_IO_BRANCH branch
33+
mkdir pages
34+
cd ./pages
35+
git clone --depth 1 https://${API_TOKEN_GITHUB}@github.com/${GITHUB_IO_REPO} -b ${GITHUB_IO_BRANCH} .
36+
37+
mkdir -p utPLSQL
38+
cd ./utPLSQL
39+
#clear out develop documentation directory and copy docs contents to it.
40+
echo "updating 'develop' documentation directory"
41+
mkdir -p ./develop
42+
rm -rf ./develop/**./* || exit 0
43+
cp -a ${DOCS_DIR} ./develop
44+
45+
# If a Tagged Build then copy to it's own directory as well and to the 'latest' release directory
46+
if [ "${GITHUB_REF_TYPE}" == "tag" ]; then
47+
echo "Creating directory ./${UTPLSQL_VERSION}"
48+
mkdir -p ./${UTPLSQL_VERSION}
49+
rm -rf ./${UTPLSQL_VERSION}/**./* || exit 0
50+
cp -a ${DOCS_DIR} ./${UTPLSQL_VERSION}
51+
echo "Populating 'latest' directory"
52+
mkdir -p ./latest
53+
rm -rf ./latest/**./* || exit 0
54+
cp -a ${DOCS_DIR} ./latest
55+
fi
56+
# Stage changes for commit
57+
git add .
58+
59+
#Check if there are doc changes, if none exit the script
60+
if [[ -z `git diff HEAD --exit-code` ]]; then
61+
echo "No changes to docs detected."
62+
exit 0
63+
fi
64+
#Changes where detected, so we need to update the version log.
65+
now=$(date +"%d %b %Y - %r")
66+
if [ ! -f index.md ]; then
67+
echo "---" >>index.md
68+
echo "layout: default" >>index.md
69+
echo "---" >>index.md
70+
echo "<!-- Auto generated from .github/scripts/push_docs_to_github_io.sh -->" >>index.md
71+
echo "# Documentation versions" >>index.md
72+
echo "" >>index.md
73+
echo "" >>index.md #- 7th line - placeholder for latest release doc
74+
echo "" >>index.md #- 8th line - placeholder for develop branch doc
75+
echo "" >>index.md
76+
echo "## Released Version Doc History" >>index.md
77+
echo "" >>index.md
78+
fi
79+
#If build running on a TAG - it's a new release - need to add it to documentation
80+
if [ "${GITHUB_REF_TYPE}" == "tag" ]; then
81+
sed -i '7s@.*@'" - [Latest ${CI_ACTION_REF_NAME} documentation](latest/) - Created $now"'@' index.md
82+
#add entry to the top of version history (line end of file - ## Released Version Doc History
83+
sed -i '12i'" - [${CI_ACTION_REF_NAME} documentation](${UTPLSQL_VERSION}/) - Created $now" index.md
84+
fi
85+
#replace 4th line in log
86+
sed -i '8s@.*@'" - [Latest development version](develop/) - Created $now"'@' index.md
87+
#Add and Commit the changes back to pages repo.
88+
git add .
89+
git commit -m "Deploy to gh-pages branch: base commit ${SHA}"
90+
# Now that we're all set up, we can push.
91+
git push --quiet origin HEAD:${GITHUB_IO_BRANCH}
92+
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env bash
2+
3+
set -v
4+
echo Current branch is "${CURRENT_BRANCH}"
5+
echo "Committing version & buildNo into branch (${CURRENT_BRANCH})"
6+
git add sonar-project.properties
7+
git add VERSION
8+
git add source/*
9+
git add docs/*
10+
git commit -m 'Updated project version after build [skip ci]'
11+
echo "Pushing to origin"
12+
git push --quiet origin HEAD:${CURRENT_BRANCH}

.travis/run_examples.sh renamed to .github/scripts/run_examples.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

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

77
"$SQLCLI" $UT3_DEVELOP_SCHEMA/$UT3_DEVELOP_SCHEMA_PASSWORD@//$CONNECTION_STR <<SQL
88
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
3+
UTPLSQL_BUILD_NO=$( expr ${GITHUB_RUN_NUMBER} + ${UTPLSQL_BUILD_NO_OFFSET} )
4+
UTPLSQL_VERSION=$(.github/scripts/get_project_version.sh)
5+
6+
echo "UTPLSQL_BUILD_NO=${UTPLSQL_BUILD_NO}" >> $GITHUB_ENV
7+
echo "UTPLSQL_VERSION=${UTPLSQL_VERSION}" >> $GITHUB_ENV
8+
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
9+
10+
echo "CURRENT_BRANCH=${CI_ACTION_REF_NAME}" >> $GITHUB_ENV

.travis/update_project_version.sh renamed to .github/scripts/update_project_version.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

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

5-
echo Current branch is "${CURRENT_BRANCH}"
5+
echo Current branch is "${CI_ACTION_REF_NAME}"
66

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

1111
echo Update version in documentation files

.travis/validate_report_files.sh renamed to .github/scripts/validate_report_files.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
#!/usr/bin/env bash
22

3+
SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
4+
35
GL_VALID=1
4-
XSD_DIR="$BUILD_DIR/.travis/xsd"
5-
XML_JAR_DIR="$BUILD_DIR/.travis/lib"
6+
XSD_DIR="${SCRIPT_DIR}/xsd"
7+
XML_JAR_DIR="${SCRIPT_DIR}/lib"
68
#XML Validator
79
XML_VALIDATOR="$XML_JAR_DIR/xml_validator.jar"
810
HTML_VALIDATOR_URL="https://validator.w3.org/nu/"
File renamed without changes.
File renamed without changes.

.github/variables/.env

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#utPLSQL install env
2+
UT3_DEVELOP_SCHEMA=UT3_DEVELOP
3+
UT3_DEVELOP_SCHEMA_PASSWORD=ut3
4+
UT3_RELEASE_VERSION_SCHEMA=UT3
5+
UT3_RELEASE_VERSION_SCHEMA_PASSWORD=ut3
6+
UT3_USER='UT3$USER#'
7+
UT3_USER_PASSWORD=ut3
8+
UT3_TESTER=UT3_TESTER
9+
UT3_TESTER_PASSWORD=ut3
10+
UT3_TESTER_HELPER=UT3_TESTER_HELPER
11+
UT3_TESTER_HELPER_PASSWORD=ut3
12+
UT3_TABLESPACE=users
13+
14+
# Database Env
15+
SQLCLI="sqlplus"
16+
OJDBC_HOME=ojdbc
17+
OJDBC_URL="https://download.oracle.com/otn-pub/otn_software/jdbc/213"
18+
ORACLE_PWD="oracle"
19+
TZ="Europe/London"
20+
21+
#Build env
22+
UTPLSQL_CLI_VERSION="3.1.8"
23+
UTPLSQL_DIR="utPLSQL_latest_release"
24+
UTPLSQL_BUILD_NO_OFFSET=3563
25+
26+
#Git configuration
27+
GIT_AUTHOR_NAME="github-actions[bot]"
28+
GIT_AUTHOR_EMAIL="github-actions[bot]@users.noreply.github.com"
29+
GIT_COMMITTER_NAME="github-actions[bot]"
30+
GIT_COMMITTER_EMAIL="github-actions[bot]@users.noreply.github.com"
31+
32+
#Docker environment for running utPLSQL install commands
33+
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"

0 commit comments

Comments
 (0)
0