Skip to content

Commit ddd3862

Browse files
committed
Fixing multi-line if statement.
Refactoring.
1 parent 12757ea commit ddd3862

File tree

8 files changed

+73
-37
lines changed

8 files changed

+73
-37
lines changed
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#!/bin/bash
22

3-
UTPLSQL_BUILD_NO=$( expr ${JOB_NUMBER} + ${UTPLSQL_BUILD_NO_OFFSET} )
3+
UTPLSQL_BUILD_NO=$( expr ${GITHUB_RUN_NUMBER} + ${UTPLSQL_BUILD_NO_OFFSET} )
44
UTPLSQL_VERSION=$(.travis/get_project_version.sh)
55

66
echo "UTPLSQL_BUILD_NO=${UTPLSQL_BUILD_NO}" >> $GITHUB_ENV
77
echo "UTPLSQL_VERSION=${UTPLSQL_VERSION}" >> $GITHUB_ENV
88
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
99

10-
echo "CURRENT_BRANCH=${BRANCH_NAME}" >> $GITHUB_ENV
10+
echo "CURRENT_BRANCH=${CI_ACTION_REF_NAME}" >> $GITHUB_ENV

.github/workflows/build.yml

Lines changed: 42 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
name: Build, test, deploy documentation
2-
env:
3-
BUILD_DIR: ${{github.workspace}}
4-
JOB_NUMBER: ${{github.run_number}}
52

63
on:
74
push:
@@ -12,7 +9,6 @@ on:
129
workflow_dispatch:
1310

1411
concurrency: ${{github.ref}}
15-
1612
defaults:
1713
run:
1814
shell: bash
@@ -21,13 +17,12 @@ jobs:
2117

2218
build-and-test:
2319
name: Build and test on ${{matrix.db_version_name}} DB
20+
runs-on: ubuntu-latest
2421
env:
2522
ORACLE_VERSION: ${{matrix.oracle-version}}
2623
CONNECTION_STR: ${{matrix.connection-str}}
2724
ORACLE_PASSWORD: oracle
2825
DOCKER_VOLUME: ${{matrix.docker-volume}}
29-
30-
runs-on: ubuntu-latest
3126
strategy:
3227
fail-fast: false
3328
matrix:
@@ -67,9 +62,10 @@ jobs:
6762
image: ${{matrix.oracle-version}}
6863
env:
6964
ORACLE_PASSWORD: oracle
70-
# credentials:
71-
# username: ${{ secrets.DOCKER_USER }}
72-
# password: ${{ secrets.DOCKER_PASSWORD }}
65+
MATRIX_JOB_ID: ${{matrix.id}}
66+
credentials:
67+
username: ${{ secrets.DOCKER_USER }}
68+
password: ${{ secrets.DOCKER_PASSWORD }}
7369
ports:
7470
- 1521:1521
7571
options: >-
@@ -82,11 +78,37 @@ jobs:
8278
- uses: actions/checkout@v2
8379
with:
8480
fetch-depth: 0
85-
- uses: nelonoel/branch-name@v1.0.1
8681
- uses: c-py/action-dotenv-to-setenv@v2
8782
with:
8883
env-file: .github/variables/.env
89-
84+
- uses: FranzDiebold/github-env-vars-action@v2 #https://github.com/marketplace/actions/github-environment-variables-action
85+
86+
- name: Print environment variables
87+
run: |
88+
echo "CI_REPOSITORY_SLUG=$CI_REPOSITORY_SLUG"
89+
echo "CI_REPOSITORY_OWNER=$CI_REPOSITORY_OWNER"
90+
echo "CI_REPOSITORY_OWNER_SLUG=$CI_REPOSITORY_OWNER_SLUG"
91+
echo "CI_REPOSITORY_NAME=$CI_REPOSITORY_NAME"
92+
echo "CI_REPOSITORY_NAME_SLUG=$CI_REPOSITORY_NAME_SLUG"
93+
echo "CI_REPOSITORY=$CI_REPOSITORY"
94+
echo "CI_REF_SLUG=$CI_REF_SLUG"
95+
echo "CI_ACTION_REF_NAME=$CI_ACTION_REF_NAME"
96+
echo "CI_ACTION_REF_NAME_SLUG=$CI_ACTION_REF_NAME_SLUG"
97+
echo "CI_REF_NAME=$CI_REF_NAME"
98+
echo "CI_REF_NAME_SLUG=$CI_REF_NAME_SLUG"
99+
echo "CI_REF=$CI_REF"
100+
echo "CI_HEAD_REF_SLUG=$CI_HEAD_REF_SLUG"
101+
echo "CI_HEAD_REF=$CI_HEAD_REF"
102+
echo "CI_BASE_REF_SLUG=$CI_BASE_REF_SLUG"
103+
echo "CI_BASE_REF=$CI_BASE_REF"
104+
echo "CI_SHA_SHORT=$CI_SHA_SHORT"
105+
echo "CI_SHA=$CI_SHA"
106+
echo "CI_ACTOR=$CI_ACTOR"
107+
echo "CI_EVENT_NAME=$CI_EVENT_NAME"
108+
echo "CI_RUN_ID=$CI_RUN_ID"
109+
echo "CI_RUN_NUMBER=$CI_RUN_NUMBER"
110+
echo "CI_WORKFLOW=$CI_WORKFLOW"
111+
echo "CI_ACTION=$CI_ACTION"
90112
91113
- name: Set build version number env variables
92114
id: set-build-version-number-vars
@@ -147,19 +169,19 @@ jobs:
147169
concurrency: publish
148170
runs-on: ubuntu-latest
149171
if: |
150-
${{ github.repository == 'utPLSQL/utPLSQL' && github.base_ref == null
151-
&& ( startsWith( github.ref, 'refs/heads/release/v' ) || github.ref == 'refs/heads/develop' )
152-
}}
172+
github.repository == 'utPLSQL/utPLSQL' &&
173+
github.base_ref == null &&
174+
( startsWith( github.ref, 'refs/heads/release/v' ) ||
175+
github.ref == 'refs/heads/develop' )
153176
154177
steps:
155178
- uses: actions/checkout@v2
156179
with:
157180
fetch-depth: 0
158-
#Populates the value of BRANCH_NAME env variable
159-
- uses: nelonoel/branch-name@v1.0.1
160181
- uses: c-py/action-dotenv-to-setenv@v2
161182
with:
162183
env-file: .github/variables/.env
184+
- uses: FranzDiebold/github-env-vars-action@v2 #https://github.com/marketplace/actions/github-environment-variables-action
163185

164186
- name: Set buid version number env variables
165187
id: set-build-version-number-vars
@@ -171,7 +193,10 @@ jobs:
171193

172194
- name: Push version update to repository
173195
id: push-version-number-update
174-
run: .travis/push_project_version.sh
196+
run: |
197+
git add sonar-project.properties VERSION source/* docs/*
198+
git commit -m 'Updated project version after build [skip ci]'
199+
git push --quiet origin HEAD:${CI_ACTION_REF_NAME}
175200
176201
- name: Copy and push documentation to utPLSQL-github-io repo
177202
id: push-documentation

.github/workflows/release_documentation.yml

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
name: Create and publish release artifacts
22
env:
3-
BUILD_DIR: ${{github.workspace}}
4-
JOB_NUMBER: ${{github.run_number}}
53
PULL_REQUEST_NAME: ${{github.head_ref}}
64
PULL_REQUEST_BRANCH: ${{github.head_ref}}
75
REPO_SLUG: ${{github.repository}}
@@ -26,8 +24,10 @@ jobs:
2624
- uses: actions/checkout@v2
2725
with:
2826
fetch-depth: 0
29-
30-
- uses: nelonoel/branch-name@v1.0.1
27+
- uses: c-py/action-dotenv-to-setenv@v2
28+
with:
29+
env-file: .github/variables/.env
30+
- uses: FranzDiebold/github-env-vars-action@v2 #https://github.com/marketplace/actions/github-environment-variables-action
3131

3232
- name: Set buid version number env variables
3333
run: .github/scripts/set_version_numbers_env.sh
@@ -43,15 +43,27 @@ jobs:
4343
- name: Update project version & build number in source code and documentation
4444
run: .travis/update_project_version.sh
4545

46-
- name: Push version update to repository
47-
run: .travis/push_project_version.sh
48-
4946
- name: Copy and push documentation to utPLSQL-github-io repo
5047
env:
5148
API_TOKEN_GITHUB: ${{ secrets.API_TOKEN_GITHUB }}
5249
run: .travis/push_docs_to_github_io.sh
5350

5451

55-
# TODO - add slack notifications
52+
slack-workflow-status:
53+
if: always()
54+
name: Post Workflow Status To Slack
55+
needs: [publish]
56+
runs-on: ubuntu-latest
57+
steps:
58+
- name: Slack Workflow Notification
59+
uses: Gamesight/slack-workflow-status@master
60+
with:
61+
# Required Input
62+
repo_token: ${{secrets.GITHUB_TOKEN}}
63+
slack_webhook_url: ${{secrets.SLACK_WEBHOOK_URL}}
64+
# Optional Input
65+
name: 'Github Actions[bot]'
66+
icon_url: 'https://octodex.github.com/images/mona-the-rivetertocat.png'
67+
5668
# TODO - add building of release archive
5769
# TODO - add publishing of release

.travis/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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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/push_docs_to_github_io.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,9 @@ if [ ! -f index.md ]; then
7878
fi
7979
#If build running on a TAG - it's a new release - need to add it to documentation
8080
if [ "${GITHUB_REF_TYPE}" == "tag" ]; then
81-
sed -i '7s@.*@'" - [Latest ${CURRENT_BRANCH} documentation](latest/) - Created $now"'@' index.md
81+
sed -i '7s@.*@'" - [Latest ${CI_ACTION_REF_NAME} documentation](latest/) - Created $now"'@' index.md
8282
#add entry to the top of version history (line end of file - ## Released Version Doc History
83-
sed -i '12i'" - [${CURRENT_BRANCH} documentation](${UTPLSQL_VERSION}/) - Created $now" index.md
83+
sed -i '12i'" - [${CI_ACTION_REF_NAME} documentation](${UTPLSQL_VERSION}/) - Created $now" index.md
8484
fi
8585
#replace 4th line in log
8686
sed -i '8s@.*@'" - [Latest development version](develop/) - Created $now"'@' index.md

.travis/update_project_version.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
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
88
find source -type f -name '*' -exec sed -i -r "s/${UTPLSQL_VERSION_PATTERN}/${UTPLSQL_BUILD_VERSION}/" {} \;

.travis/validate_report_files.sh

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

33
GL_VALID=1
4-
XSD_DIR="$BUILD_DIR/.travis/xsd"
5-
XML_JAR_DIR="$BUILD_DIR/.travis/lib"
4+
XSD_DIR=".travis/xsd"
5+
XML_JAR_DIR=".travis/lib"
66
#XML Validator
77
XML_VALIDATOR="$XML_JAR_DIR/xml_validator.jar"
88
HTML_VALIDATOR_URL="https://validator.w3.org/nu/"

0 commit comments

Comments
 (0)