Skip to content

Commit 532be8d

Browse files
committed
Externalizing env variables.
Cleanup and refactoring.
1 parent 82c4d21 commit 532be8d

9 files changed

Lines changed: 209 additions & 319 deletions

File tree

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 ${JOB_NUMBER} + ${UTPLSQL_BUILD_NO_OFFSET} )
4+
UTPLSQL_VERSION=$(.travis/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=${BRANCH_NAME}" >> $GITHUB_ENV

.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"

.github/workflows/build.yml

Lines changed: 110 additions & 196 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,7 @@
1-
name: Deploy and test
1+
name: Build and test
22
env:
3-
#utPLSQL install env
4-
UT3_DEVELOP_SCHEMA: UT3_DEVELOP
5-
UT3_DEVELOP_SCHEMA_PASSWORD: ut3
6-
UT3_RELEASE_VERSION_SCHEMA: UT3
7-
UT3_RELEASE_VERSION_SCHEMA_PASSWORD: ut3
8-
UT3_USER: 'UT3$USER#'
9-
UT3_USER_PASSWORD: ut3
10-
UT3_TESTER: UT3_TESTER
11-
UT3_TESTER_PASSWORD: ut3
12-
UT3_TESTER_HELPER: UT3_TESTER_HELPER
13-
UT3_TESTER_HELPER_PASSWORD: ut3
14-
UT3_TABLESPACE: users
15-
#Build env
163
BUILD_DIR: ${{github.workspace}}
17-
JOB_ID: ${{github.run_id}}
184
JOB_NUMBER: ${{github.run_number}}
19-
PULL_REQUEST_NAME: ${{github.head_ref}}
20-
PULL_REQUEST_BRANCH: ${{github.head_ref}}
21-
TAG_NAME: ${TRAVIS_TAG}
22-
REPO_SLUG: ${{github.repository}}
23-
PR_SLUG: ${{github.repository}}
24-
UTPLSQL_REPO: "utPLSQL/utPLSQL"
25-
UTPLSQL_BUILD_NO_OFFSET: 3563
26-
# Database Env
27-
SQLCLI: "sqlplus"
28-
OJDBC_HOME: ${{github.workspace}}/ojdbc
29-
OJDBC_URL: "https://download.oracle.com/otn-pub/otn_software/jdbc/213"
30-
ORACLE_PWD: "oracle"
31-
DOCKHER_HUB_REPO: "utplsqlv3/oracledb"
32-
#utPLSQL released version directory
33-
UTPLSQL_DIR: "utPLSQL_latest_release"
34-
SELFTESTING_BRANCH: ${TRAVIS_BRANCH}
35-
UTPLSQL_CLI_VERSION: "3.1.8"
36-
TZ: "Europe/London"
37-
# Maven
38-
MAVEN_HOME: /usr/local/maven
39-
MAVEN_CFG: $HOME/.m2
405

416
on:
427
push:
@@ -46,189 +11,138 @@ on:
4611

4712
workflow_dispatch:
4813

14+
defaults:
15+
run:
16+
shell: bash
17+
4918
jobs:
5019

51-
# build:
52-
# env:
53-
# ORACLE_VERSION: ${{matrix.oracle-version}}
54-
# CONNECTION_STR: ${{matrix.connection-str}}
55-
# ORACLE_PASSWORD: oracle
56-
# DOCKER_VOLUME: ${{matrix.docker-volume}}
57-
# 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"
58-
#
59-
# runs-on: ubuntu-latest
60-
# strategy:
61-
# fail-fast: false
62-
# matrix:
63-
# include:
64-
# - oracle-version: "gvenzl/oracle-xe:11-full"
65-
# connection-str: '127.0.0.1:1521/XE'
66-
## TODO - need to add healthcheck.sh into our containers
67-
## - oracle-version: "utplsqlv3/oracledb:12c-r1-se2-small"
68-
## connection-str: '127.0.0.1:1521/ORCLCDB'
69-
## - oracle-version: "utplsqlv3/oracledb:12c-r2-se2-small"
70-
## connection-str: '127.0.0.1:1521/ORCLCDB'
71-
# - oracle-version: "gvenzl/oracle-xe:18-slim"
72-
# connection-str: '127.0.0.1:1521/XE'
73-
## - oracle-version: "utplsqlv3/oracledb:18c-se2-small"
74-
## connection-str: '127.0.0.1:1521/ORCLCDB'
75-
## - oracle-version: "utplsqlv3/oracledb:19c-se2-small"
76-
## connection-str: '127.0.0.1:1521/ORCLCDB'
77-
# - oracle-version: "gvenzl/oracle-xe:21-slim"
78-
# connection-str: '127.0.0.1:1521/XE'
79-
#
80-
# services:
81-
# oracle:
82-
# image: ${{matrix.oracle-version}}
83-
# env:
84-
# ORACLE_PASSWORD: oracle
85-
## credentials:
86-
## username: ${{ secrets.DOCKER_USER }}
87-
## password: ${{ secrets.DOCKER_PASSWORD }}
88-
# ports:
89-
# - 1521:1521
90-
# options: >-
91-
# --health-cmd healthcheck.sh
92-
# --health-interval 10s
93-
# --health-timeout 5s
94-
# --health-retries 10
95-
# -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
96-
#
97-
# steps:
98-
# - uses: actions/checkout@v2
99-
# with:
100-
# fetch-depth: 0
101-
#
102-
# - uses: nelonoel/branch-name@v1.0.1
103-
#
104-
# - name: Set dynamic environment variables
105-
# run: |
106-
# echo "CURRENT_BRANCH=${BRANCH_NAME}" >> $GITHUB_ENV
107-
# echo "UTPLSQL_BUILD_NO=$( expr ${{github.run_number}} + ${UTPLSQL_BUILD_NO_OFFSET} )" >> $GITHUB_ENV
108-
# echo "UTPLSQL_VERSION=$(.travis/get_project_version.sh)" >> $GITHUB_ENV
109-
# shell: bash
110-
#
111-
# - name: Set buid version number
112-
# run: 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
113-
# shell: bash
114-
#
115-
# - name: print variables
116-
# run: |
117-
# echo github.run_number is ${{ github.run_number }}
118-
# echo UTPLSQL_BUILD_NO is $UTPLSQL_BUILD_NO
119-
# echo UTPLSQL_VERSION is $UTPLSQL_VERSION
120-
# echo UTPLSQL_BUILD_VERSION is $UTPLSQL_BUILD_VERSION
121-
#
122-
# - name: Update project version & build number to verify that code is deployable after the update
123-
# run: .travis/update_project_version.sh
124-
#
125-
# - name: Download latest utPLSQL release
126-
# run: git clone --depth=1 --branch=main https://github.com/utPLSQL/utPLSQL.git $UTPLSQL_DIR
127-
#
128-
# - name: Add OJDBC home
129-
# run: mkdir -p ${OJDBC_HOME} && curl -Lk -o ${OJDBC_HOME}/ojdbc8.jar ${OJDBC_URL}/ojdbc8.jar && curl -Lk -o ${OJDBC_HOME}/orai18n.jar ${OJDBC_URL}/orai18n.jar
130-
#
131-
# - name: Install utPLSQL-cli
132-
# run: curl -Lk -o utPLSQL-cli.zip "https://github.com/utPLSQL/utPLSQL-cli/releases/download/v3.1.8/utPLSQL-cli.zip" && unzip utPLSQL-cli.zip && chmod -R u+x utPLSQL-cli
133-
#
134-
# - name: Update privileges on sources
135-
# run: chmod -R go+w ./{source,test,examples,${UTPLSQL_DIR}/source}
136-
#
137-
# - name: Install utPLSQL
138-
# run: docker run --rm -v $(pwd):/utPLSQL -w /utPLSQL --network host --entrypoint bash ${DOCKER_ENV} ${ORACLE_VERSION} .travis/install.sh
139-
#
140-
# - name: Install utPLSQL release
141-
# run: docker run --rm -v $(pwd):/utPLSQL -w /utPLSQL --network host --entrypoint bash ${DOCKER_ENV} ${ORACLE_VERSION} ./.travis/install_utplsql_release.sh
142-
#
143-
# - name: Run Examples
144-
# run: docker run --rm -v $(pwd):/utPLSQL -w /utPLSQL --network host --entrypoint bash ${DOCKER_ENV} ${ORACLE_VERSION} ./.travis/run_examples.sh
145-
#
146-
# - name: Install tests
147-
# run: docker run --rm -v $(pwd):/utPLSQL -w /utPLSQL --network host --entrypoint bash ${DOCKER_ENV} ${ORACLE_VERSION} ./test/install_tests.sh
148-
#
149-
# - name: Run Tests
150-
# run: bash test/run_tests.sh
151-
#
152-
# - name: Validate utPLSQL reports format
153-
# run: bash .travis/validate_report_files.sh
154-
#
155-
# - name: SonarCloud Scan
156-
# uses: SonarSource/sonarcloud-github-action@master
157-
# env:
158-
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
159-
# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
20+
build:
21+
env:
22+
ORACLE_VERSION: ${{matrix.oracle-version}}
23+
CONNECTION_STR: ${{matrix.connection-str}}
24+
ORACLE_PASSWORD: oracle
25+
DOCKER_VOLUME: ${{matrix.docker-volume}}
16026

161-
publish:
162-
# needs: build
16327
runs-on: ubuntu-latest
28+
strategy:
29+
fail-fast: false
30+
matrix:
31+
include:
32+
- oracle-version: "gvenzl/oracle-xe:11-full"
33+
connection-str: '127.0.0.1:1521/XE'
34+
# TODO - need to add healthcheck.sh into our containers
35+
# - oracle-version: "utplsqlv3/oracledb:12c-r1-se2-small"
36+
# connection-str: '127.0.0.1:1521/ORCLCDB'
37+
# - oracle-version: "utplsqlv3/oracledb:12c-r2-se2-small"
38+
# connection-str: '127.0.0.1:1521/ORCLCDB'
39+
- oracle-version: "gvenzl/oracle-xe:18-slim"
40+
connection-str: '127.0.0.1:1521/XE'
41+
# - oracle-version: "utplsqlv3/oracledb:18c-se2-small"
42+
# connection-str: '127.0.0.1:1521/ORCLCDB'
43+
# - oracle-version: "utplsqlv3/oracledb:19c-se2-small"
44+
# connection-str: '127.0.0.1:1521/ORCLCDB'
45+
- oracle-version: "gvenzl/oracle-xe:21-slim"
46+
connection-str: '127.0.0.1:1521/XE'
47+
48+
services:
49+
oracle:
50+
image: ${{matrix.oracle-version}}
51+
env:
52+
ORACLE_PASSWORD: oracle
53+
# credentials:
54+
# username: ${{ secrets.DOCKER_USER }}
55+
# password: ${{ secrets.DOCKER_PASSWORD }}
56+
ports:
57+
- 1521:1521
58+
options: >-
59+
--health-cmd healthcheck.sh
60+
--health-interval 10s
61+
--health-timeout 5s
62+
--health-retries 10
16463
16564
steps:
16665
- uses: actions/checkout@v2
16766
with:
16867
fetch-depth: 0
169-
17068
- uses: nelonoel/branch-name@v1.0.1
69+
- uses: c-py/action-dotenv-to-setenv@v2
70+
with:
71+
env-file: .github/variables/.env
72+
73+
74+
- name: Set buid version number env variables
75+
run: .github/scripts/set_version_numbers_env.sh
76+
77+
- name: Update project version & build number to verify that code is deployable after the update
78+
run: .travis/update_project_version.sh
79+
80+
- name: Download latest utPLSQL release
81+
run: git clone --depth=1 --branch=main https://github.com/utPLSQL/utPLSQL.git $UTPLSQL_DIR
82+
83+
- name: Add OJDBC home
84+
run: mkdir -p ${OJDBC_HOME} && curl -Lk -o ${OJDBC_HOME}/ojdbc8.jar ${OJDBC_URL}/ojdbc8.jar && curl -Lk -o ${OJDBC_HOME}/orai18n.jar ${OJDBC_URL}/orai18n.jar
85+
86+
- name: Install utPLSQL-cli
87+
run: curl -Lk -o utPLSQL-cli.zip "https://github.com/utPLSQL/utPLSQL-cli/releases/download/v3.1.8/utPLSQL-cli.zip" && unzip utPLSQL-cli.zip && chmod -R u+x utPLSQL-cli
88+
89+
- name: Update privileges on sources
90+
run: chmod -R go+w ./{source,test,examples,${UTPLSQL_DIR}/source}
91+
92+
- name: Install utPLSQL
93+
run: docker run --rm -v $(pwd):/utPLSQL -w /utPLSQL --network host --entrypoint bash ${DOCKER_ENV} ${ORACLE_VERSION} .travis/install.sh
94+
95+
- name: Install utPLSQL release
96+
run: docker run --rm -v $(pwd):/utPLSQL -w /utPLSQL --network host --entrypoint bash ${DOCKER_ENV} ${ORACLE_VERSION} ./.travis/install_utplsql_release.sh
17197

172-
- name: Set dynamic environment variables
173-
run: |
174-
echo "CURRENT_BRANCH=${BRANCH_NAME}" >> $GITHUB_ENV
175-
echo "UTPLSQL_BUILD_NO=$( expr ${{github.run_number}} + ${UTPLSQL_BUILD_NO_OFFSET} )" >> $GITHUB_ENV
176-
echo "UTPLSQL_VERSION=$(.travis/get_project_version.sh)" >> $GITHUB_ENV
177-
shell: bash
98+
- name: Run Examples
99+
run: docker run --rm -v $(pwd):/utPLSQL -w /utPLSQL --network host --entrypoint bash ${DOCKER_ENV} ${ORACLE_VERSION} ./.travis/run_examples.sh
178100

179-
- name: Set buid version number
180-
run: 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
181-
shell: bash
101+
- name: Install tests
102+
run: docker run --rm -v $(pwd):/utPLSQL -w /utPLSQL --network host --entrypoint bash ${DOCKER_ENV} ${ORACLE_VERSION} ./test/install_tests.sh
182103

104+
- name: Run Tests
105+
run: bash test/run_tests.sh
183106

184-
- name: Install MkDocs
185-
run: pip install mkdocs
107+
- name: Validate utPLSQL reports format
108+
run: bash .travis/validate_report_files.sh
109+
110+
- name: SonarCloud Scan
111+
uses: SonarSource/sonarcloud-github-action@master
112+
env:
113+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
114+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
115+
116+
publish:
117+
needs: build
118+
runs-on: ubuntu-latest
119+
if: |
120+
${{ github.repository == 'utPLSQL/utPLSQL' && github.base_ref == null
121+
&& ( startsWith( github.ref, 'refs/heads/release/v' ) || github.ref == 'refs/heads/develop' )
122+
}}
123+
124+
steps:
125+
- uses: actions/checkout@v2
126+
with:
127+
fetch-depth: 0
128+
#Populates the value of BRANCH_NAME env variable
129+
- uses: nelonoel/branch-name@v1.0.1
130+
- uses: c-py/action-dotenv-to-setenv@v2
131+
with:
132+
env-file: .github/variables/.env
133+
134+
- name: Set buid version number env variables
135+
run: .github/scripts/set_version_numbers_env.sh
186136

187137
- name: Update project version & build number in source code and documentation
188138
run: .travis/update_project_version.sh
189-
shell: bash
190139

191140
- name: Push version update to repository
192-
uses: test-room-7/action-update-file@v1
193-
with:
194-
file-path: |
195-
sonar-project.properties
196-
VERSION
197-
source/**
198-
docs/**
199-
commit-msg: Updated project version after build [skip ci]
200-
github-token: ${{ secrets.API_TOKEN_GITHUB }}
201-
branch: ${{ env.CURRENT_BRANCH }}
202-
if: |
203-
${{
204-
github.ref_type == 'branch'
205-
&& github.repository == 'utPLSQL/utPLSQL'
206-
&& ( startsWith(env.CURRENT_BRANCH,'release/')
207-
|| env.CURRENT_BRANCH == 'develop'
208-
|| env.CURRENT_BRANCH == 'feature/github_actions'
209-
)
210-
}}
141+
run: .travis/push_project_version.sh
211142

212143
- name: Copy and push documentation to utPLSQL-github-io repo
213144
env:
214145
API_TOKEN_GITHUB: ${{ secrets.API_TOKEN_GITHUB }}
215146
run: .travis/push_docs_to_github_io.sh
216-
shell: bash
217-
if: |
218-
${{
219-
github.repository == 'utPLSQL/utPLSQL'
220-
&& (github.ref_type == 'branch'
221-
&& ( startsWith(env.CURRENT_BRANCH,'release/')
222-
|| env.CURRENT_BRANCH == 'develop'
223-
|| env.CURRENT_BRANCH == 'feature/github_actions'
224-
)
225-
|| github.ref_type == 'tag'
226-
)
227-
}}
228-
229-
230147

231148
# TODO - add slack notifications
232-
# TODO - add push of documentation
233-
# TODO - add building of release archive
234-
# TODO - add publishing of release

0 commit comments

Comments
 (0)