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 1 commit
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
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
Prev Previous commit
Next Next commit
Adding publishing of project version updates
  • Loading branch information
jgebal committed Jan 13, 2022
commit 9307524cd9a8ac309e694ddf2191ea47c0a1dcf1
247 changes: 152 additions & 95 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: Deploy and test
env:
#utPLSQL install env
UT3_DEVELOP_SCHEMA: UT3_DEVELOP
UT3_DEVELOP_SCHEMA_PASSWORD: ut3
UT3_RELEASE_VERSION_SCHEMA: UT3
Expand All @@ -11,22 +12,17 @@ env:
UT3_TESTER_HELPER: UT3_TESTER_HELPER
UT3_TESTER_HELPER_PASSWORD: ut3
UT3_TABLESPACE: users
#Build env
BUILD_DIR: ${{github.workspace}}
JOB_ID: ${{github.run_id}}
JOB_NUMBER: ${{github.run_number}}
PULL_REQUEST_NAME: ${github.head_ref}
PULL_REQUEST_NAME: ${{github.head_ref}}
PULL_REQUEST_BRANCH: ${{github.head_ref}}
TAG_NAME: ${TRAVIS_TAG}
REPO_SLUG: ${{github.repository}}
PR_SLUG: ${{github.repository}}
UTPLSQL_REPO: "utPLSQL/utPLSQL"
UTPLSQL_BUILD_NO_OFFSET: 3563
UTPLSQL_BUILD_NO: $( expr ${{github.run_number}} + ${UTPLSQL_BUILD_NO_OFFSET} )
UTPLSQL_VERSION: $(. .travis/get_project_version.sh)
UTPLSQL_BUILD_VERSION: $(. .travis/get_project_build_version.sh)
UTPLSQL_SOURCES_DIR: 'source'
UTPLSQL_BUILD_USER_NAME: "Travis CI"
CACHE_DIR: $HOME/.cache
# Database Env
SQLCLI: "sqlplus"
OJDBC_HOME: ${{github.workspace}}/ojdbc
Expand All @@ -51,52 +47,120 @@ on:
workflow_dispatch:

jobs:
build:

env:
ORACLE_VERSION: ${{matrix.oracle-version}}
CONNECTION_STR: ${{matrix.connection-str}}
ORACLE_PASSWORD: oracle
DOCKER_VOLUME: ${{matrix.docker-volume}}
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"

# build:
# env:
# ORACLE_VERSION: ${{matrix.oracle-version}}
# CONNECTION_STR: ${{matrix.connection-str}}
# ORACLE_PASSWORD: oracle
# DOCKER_VOLUME: ${{matrix.docker-volume}}
# 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"
#
# runs-on: ubuntu-latest
# strategy:
# fail-fast: false
# matrix:
# include:
# - oracle-version: "gvenzl/oracle-xe:11-full"
# connection-str: '127.0.0.1:1521/XE'
## TODO - need to add healthcheck.sh into our containers
## - oracle-version: "utplsqlv3/oracledb:12c-r1-se2-small"
## connection-str: '127.0.0.1:1521/ORCLCDB'
## - oracle-version: "utplsqlv3/oracledb:12c-r2-se2-small"
## connection-str: '127.0.0.1:1521/ORCLCDB'
# - oracle-version: "gvenzl/oracle-xe:18-slim"
# connection-str: '127.0.0.1:1521/XE'
## - oracle-version: "utplsqlv3/oracledb:18c-se2-small"
## connection-str: '127.0.0.1:1521/ORCLCDB'
## - oracle-version: "utplsqlv3/oracledb:19c-se2-small"
## connection-str: '127.0.0.1:1521/ORCLCDB'
# - oracle-version: "gvenzl/oracle-xe:21-slim"
# connection-str: '127.0.0.1:1521/XE'
#
# services:
# oracle:
# image: ${{matrix.oracle-version}}
# env:
# ORACLE_PASSWORD: oracle
## credentials:
## username: ${{ secrets.DOCKER_USER }}
## password: ${{ secrets.DOCKER_PASSWORD }}
# ports:
# - 1521:1521
# options: >-
# --health-cmd healthcheck.sh
# --health-interval 10s
# --health-timeout 5s
# --health-retries 10
# -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
#
# steps:
# - uses: actions/checkout@v2
# with:
# fetch-depth: 0
#
# - uses: nelonoel/branch-name@v1.0.1
#
# - name: Set dynamic environment variables
# run: |
# echo "CURRENT_BRANCH=${BRANCH_NAME}" >> $GITHUB_ENV
# echo "UTPLSQL_BUILD_NO=$( expr ${{github.run_number}} + ${UTPLSQL_BUILD_NO_OFFSET} )" >> $GITHUB_ENV
# echo "UTPLSQL_VERSION=$(.travis/get_project_version.sh)" >> $GITHUB_ENV
# shell: bash
#
# - name: Set buid version number
# 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
# shell: bash
#
# - name: print variables
# run: |
# echo github.run_number is ${{ github.run_number }}
# echo UTPLSQL_BUILD_NO is $UTPLSQL_BUILD_NO
# echo UTPLSQL_VERSION is $UTPLSQL_VERSION
# echo UTPLSQL_BUILD_VERSION is $UTPLSQL_BUILD_VERSION
#
# - name: Update project version & build number to verify that code is deployable after the update
# run: .travis/update_project_version.sh
#
# - name: Download latest utPLSQL release
# run: git clone --depth=1 --branch=main https://github.com/utPLSQL/utPLSQL.git $UTPLSQL_DIR
#
# - name: Add OJDBC home
# 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
#
# - name: Install utPLSQL-cli
# 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
#
# - name: Update privileges on sources
# run: chmod -R go+w ./{source,test,examples,${UTPLSQL_DIR}/source}
#
# - name: Install utPLSQL
# run: docker run --rm -v $(pwd):/utPLSQL -w /utPLSQL --network host --entrypoint bash ${DOCKER_ENV} ${ORACLE_VERSION} .travis/install.sh
#
# - name: Install utPLSQL release
# run: docker run --rm -v $(pwd):/utPLSQL -w /utPLSQL --network host --entrypoint bash ${DOCKER_ENV} ${ORACLE_VERSION} ./.travis/install_utplsql_release.sh
#
# - name: Run Examples
# run: docker run --rm -v $(pwd):/utPLSQL -w /utPLSQL --network host --entrypoint bash ${DOCKER_ENV} ${ORACLE_VERSION} ./.travis/run_examples.sh
#
# - name: Install tests
# run: docker run --rm -v $(pwd):/utPLSQL -w /utPLSQL --network host --entrypoint bash ${DOCKER_ENV} ${ORACLE_VERSION} ./test/install_tests.sh
#
# - name: Run Tests
# run: bash test/run_tests.sh
#
# - name: Validate utPLSQL reports format
# run: bash .travis/validate_report_files.sh
#
# - name: SonarCloud Scan
# uses: SonarSource/sonarcloud-github-action@master
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

publish:
# needs: build
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- oracle-version: "gvenzl/oracle-xe:11-full"
connection-str: '127.0.0.1:1521/XE'
# TODO - need to add healthcheck.sh into our containers
# - oracle-version: "utplsqlv3/oracledb:12c-r1-se2-small"
# connection-str: '127.0.0.1:1521/ORCLCDB'
# - oracle-version: "utplsqlv3/oracledb:12c-r2-se2-small"
# connection-str: '127.0.0.1:1521/ORCLCDB'
- oracle-version: "gvenzl/oracle-xe:18-slim"
connection-str: '127.0.0.1:1521/XE'
# - oracle-version: "utplsqlv3/oracledb:18c-se2-small"
# connection-str: '127.0.0.1:1521/ORCLCDB'
# - oracle-version: "utplsqlv3/oracledb:19c-se2-small"
# connection-str: '127.0.0.1:1521/ORCLCDB'
- oracle-version: "gvenzl/oracle-xe:21-slim"
connection-str: '127.0.0.1:1521/XE'

services:
oracle:
image: ${{matrix.oracle-version}}
env:
ORACLE_PASSWORD: oracle
# credentials:
# username: ${{ secrets.DOCKER_USER }}
# password: ${{ secrets.DOCKER_PASSWORD }}
ports:
- 1521:1521
options: >-
--health-cmd healthcheck.sh
--health-interval 10s
--health-timeout 5s
--health-retries 10
-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

steps:
- uses: actions/checkout@v2
Expand All @@ -109,51 +173,44 @@ jobs:
run: |
echo "CURRENT_BRANCH=${BRANCH_NAME}" >> $GITHUB_ENV
echo "UTPLSQL_BUILD_NO=$( expr ${{github.run_number}} + ${UTPLSQL_BUILD_NO_OFFSET} )" >> $GITHUB_ENV
echo "UTPLSQL_VERSION=$(. .travis/get_project_version.sh)" >> $GITHUB_ENV
echo UTPLSQL_BUILD_VERSION=$(sed -E "s/(v?[0-9]+\.)([0-9]+\.)([0-9]+)(-.*)?/\1\2\3\.${UTPLSQL_BUILD_NO}\4/" <<< "${UTPLSQL_VERSION}") >> $GITHUB_ENV
echo "UTPLSQL_VERSION=$(.travis/get_project_version.sh)" >> $GITHUB_ENV
shell: bash

# - name: print variables
# run: |
# echo github.run_number is ${{ github.run_number }}
# echo UTPLSQL_BUILD_NO is $UTPLSQL_BUILD_NO
# echo UTPLSQL_VERSION is $UTPLSQL_VERSION
# echo UTPLSQL_BUILD_VERSION is $UTPLSQL_BUILD_VERSION

- name: Update project version & build number
run: .travis/update_project_version.sh

- name: Download latest utPLSQL release
run: git clone --depth=1 --branch=main https://github.com/utPLSQL/utPLSQL.git $UTPLSQL_DIR

- name: Add OJDBC home
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

- name: Install utPLSQL-cli
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

- name: Update privileges on sources
run: chmod -R go+w ./{source,test,examples,${UTPLSQL_DIR}/source}
- name: Set buid version number
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
shell: bash

- name: Install utPLSQL
run: docker run --rm -v $(pwd):/utPLSQL -w /utPLSQL --network host --entrypoint bash ${DOCKER_ENV} ${ORACLE_VERSION} .travis/install.sh

- name: Install utPLSQL release
run: docker run --rm -v $(pwd):/utPLSQL -w /utPLSQL --network host --entrypoint bash ${DOCKER_ENV} ${ORACLE_VERSION} ./.travis/install_utplsql_release.sh
- name: Install MkDocs
run: pip install mkdocs

- name: Run Examples
run: docker run --rm -v $(pwd):/utPLSQL -w /utPLSQL --network host --entrypoint bash ${DOCKER_ENV} ${ORACLE_VERSION} ./.travis/run_examples.sh

- name: Install tests
run: docker run --rm -v $(pwd):/utPLSQL -w /utPLSQL --network host --entrypoint bash ${DOCKER_ENV} ${ORACLE_VERSION} ./test/install_tests.sh

- name: Run Tests
run: bash test/run_tests.sh

- name: Validate utPLSQL reports format
run: bash .travis/validate_report_files.sh

- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
- name: Update project version & build number in source code and documentation
run: .travis/update_project_version.sh
shell: bash

- name: Push version update to repository
uses: test-room-7/action-update-file@v1
with:
file-path: |
sonar-project.properties
VERSION
source/**
docs/**
commit-msg: Updated project version after build [skip ci]
github-token: ${{ secrets.PUSH_TOKEN }}
branch: ${{ env.CURRENT_BRANCH }}
if: |
${{
github.ref_type == 'branch'
&& github.repository == 'utPLSQL/utPLSQL'
&& ( startsWith(env.CURRENT_BRANCH,'release/')
|| env.CURRENT_BRANCH == 'develop'
|| env.CURRENT_BRANCH == 'feature/github_actions'
)
}}


# TODO - add slack notifications
# TODO - add push of documentation
# TODO - add building of release archive
# TODO - add publishing of release
12 changes: 12 additions & 0 deletions .travis/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}
18 changes: 0 additions & 18 deletions .travis/push_release_version.sh

This file was deleted.

2 changes: 1 addition & 1 deletion .travis/update_project_version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ UTPLSQL_VERSION_PATTERN="v?([0-9]+\.){3}[0-9]+[^']*"
echo Current branch is "${CURRENT_BRANCH}"

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
0