|
name: Build, test, deploy documentation |
|
on: |
|
push: |
|
branches-ignore: [ main ] |
|
pull_request: |
|
branches: [ develop ] |
|
schedule: |
|
- cron: '0 8 * * 5' # run scheduled at 8:00 AM every Friday |
|
timezone: "Europe/Nicosia" |
|
|
|
workflow_dispatch: |
|
|
|
concurrency: ${{github.ref}} |
|
defaults: |
|
run: |
|
shell: bash |
|
|
|
jobs: |
|
|
|
build: |
|
name: Build and test on ${{matrix.db_version_name}} DB |
|
runs-on: ubuntu-latest |
|
timeout-minutes: 90 |
|
env: |
|
ORACLE_VERSION: ${{matrix.oracle-version}} |
|
ORACLE_SID: ${{matrix.oracle-sid}} |
|
CONNECTION_STR: ${{ format( '127.0.0.1:1521/{0}', matrix.oracle-sid ) }} |
|
ORACLE_PASSWORD: oracle |
|
DOCKER_VOLUME: ${{matrix.docker-volume}} |
|
strategy: |
|
fail-fast: false |
|
matrix: |
|
include: |
|
- id: 1 |
|
db_version_name: '19se' |
|
oracle-sid: 'ORCLCDB' |
|
oracle-version: "utplsqlv3/oracledb:19c-se2-small" |
|
check-coding-style: true |
|
validate-utplsql-uninstall: true |
|
- id: 2 |
|
db_version_name: '21XE' |
|
oracle-sid: 'XE' |
|
oracle-version: "gvenzl/oracle-xe:21-slim-faststart" |
|
- id: 3 |
|
db_version_name: '23-free' |
|
oracle-sid: 'FREEPDB1' |
|
oracle-version: "gvenzl/oracle-free:23-slim-faststart" |
|
fips-enabled: true |
|
run-sonar-scanner: true |
|
services: |
|
html_checker: |
|
image: ghcr.io/validator/validator:latest |
|
options: >- |
|
-p 8888:8888 |
|
oracle: |
|
image: ${{matrix.oracle-version}} |
|
env: |
|
ORACLE_PASSWORD: oracle |
|
credentials: |
|
username: ${{ secrets.DOCKER_USER }} |
|
password: ${{ secrets.DOCKER_PASSWORD }} |
|
volumes: |
|
- ${{github.workspace}}:/utPLSQL |
|
ports: |
|
- 1521:1521 |
|
options: >- |
|
--health-interval 10s |
|
--health-timeout 5s |
|
--health-retries 10 |
|
--name oracle |
|
--health-cmd healthcheck.sh |
|
|
|
steps: |
|
- uses: actions/checkout@v4 |
|
with: |
|
fetch-depth: 0 |
|
- uses: c-py/action-dotenv-to-setenv@v5 |
|
with: |
|
env-file: .github/variables/.env |
|
- uses: FranzDiebold/github-env-vars-action@v2.8.0 #https://github.com/marketplace/actions/github-environment-variables-action |
|
|
|
- name: Set build version number env variables |
|
id: set-build-version-number-vars |
|
run: .github/scripts/set_version_numbers_env.sh |
|
|
|
- name: Update project version & build number to verify that code is deployable after the update |
|
id: update-project-version |
|
run: .github/scripts/update_project_version.sh |
|
|
|
- name: Download utPLSQL release for testing |
|
# For PR build - test using target branch as framework, for branch build use self as testing framework |
|
run: git clone --depth=1 --branch=${CI_BASE_REF:-$CI_REF_NAME} https://github.com/utPLSQL/utPLSQL.git $UTPLSQL_DIR |
|
|
|
- name: Enable FIPS 140 on Oracle DB |
|
id: enable-fips |
|
if: ${{ matrix.fips-enabled == true }} |
|
run: | |
|
docker exec oracle bash -c " |
|
echo \"ALTER SYSTEM SET DBFIPS_140=TRUE SCOPE=SPFILE; |
|
SHUTDOWN IMMEDIATE; |
|
STARTUP; |
|
PROMPT Should show true for DBFIPS_140 |
|
SELECT name, value FROM v$parameter WHERE name = 'DBFIPS_140'; |
|
EXIT;\" | sqlplus -s / as sysdba |
|
" |
|
docker exec oracle bash -c "until healthcheck.sh; do echo 'Waiting for DB restart...'; sleep 1; done" |
|
- name: Update privileges on sources |
|
run: chmod -R go+w ./{source,test,examples,${UTPLSQL_DIR}/source} |
|
|
|
- name: Cache OJDBC jars |
|
id: cache-ojdbc |
|
uses: actions/cache@v4 |
|
with: |
|
path: ${{ env.OJDBC_HOME }} |
|
key: ${{ runner.os }}-ojdbc-${{ env.OJDBC_URL }}-v1 |
|
|
|
- name: Add OJDBC home |
|
if: steps.cache-ojdbc.outputs.cache-hit != 'true' |
|
id: get-ojdbc |
|
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: Cache utPLSQL-cli |
|
id: cache-utplsql-cli |
|
uses: actions/cache@v4 |
|
with: |
|
path: utPLSQL-cli |
|
key: ${{ runner.os }}-utplsql-cli-v3.1.8 |
|
|
|
- name: Install utPLSQL-cli |
|
if: steps.cache-utplsql-cli.outputs.cache-hit != 'true' |
|
id: install-utplsql-cli |
|
run: curl -Lk -o utPLSQL-cli.zip "https://github.com/utPLSQL/utPLSQL-cli/releases/download/3.1.9/utPLSQL-cli.zip" && unzip utPLSQL-cli.zip && chmod -R u+x utPLSQL-cli |
|
|
|
- name: Install utPLSQL |
|
id: install-utplsql |
|
run: docker exec -w /utPLSQL ${DOCKER_ENV} oracle .github/scripts/install.sh |
|
|
|
- name: Check code style |
|
if: ${{ matrix.check-style == true }} |
|
id: check-coding-style |
|
run: docker exec -w /utPLSQL ${DOCKER_ENV} oracle "$SQLCLI" ${UT3_DEVELOP_SCHEMA}/${UT3_DEVELOP_SCHEMA_PASSWORD}@//${CONNECTION_STR} @/utPLSQL/development/utplsql_style_check.sql |
|
|
|
- name: Validate utPLSQL uninstall |
|
if: ${{ matrix.validate-utplsql-uninstall == true }} |
|
id: validate-uninstall |
|
run: docker exec -w /utPLSQL ${DOCKER_ENV} oracle .github/scripts/uninstall_validate_utplsql.sh |
|
|
|
- name: Reinstall utPLSQL |
|
if: ${{ matrix.validate-utplsql-uninstall == true }} |
|
id: reinstall-utplsql |
|
run: docker exec -w /utPLSQL ${DOCKER_ENV} oracle .github/scripts/install.sh |
|
|
|
- name: Create test users |
|
id: create-test-users |
|
run: docker exec -w /utPLSQL ${DOCKER_ENV} oracle .github/scripts/create_test_users.sh |
|
|
|
- name: Install utPLSQL release |
|
id: install-utplsql-release |
|
run: docker exec -w /utPLSQL ${DOCKER_ENV} oracle .github/scripts/install_utplsql_release.sh |
|
|
|
- name: Run Examples |
|
id: run-examples |
|
run: docker exec -w /utPLSQL ${DOCKER_ENV} oracle .github/scripts/run_examples.sh |
|
|
|
- name: Install tests |
|
id: install-tests |
|
run: docker exec -w /utPLSQL ${DOCKER_ENV} oracle test/install_tests.sh |
|
|
|
- name: Run Tests |
|
id: run-tests |
|
run: test/run_tests.sh |
|
|
|
#Start Needed to diagnose occasional failures of DB on test runs |
|
- name: Prepare diagnostic directory |
|
id: preapre-oracle-diag-dir |
|
if: ${{ always() && steps.run-tests.outcome == 'failure' }} |
|
run: | |
|
mkdir database-diag |
|
chmod +777 database-diag |
|
- name: Get ORACLE_BASE/diag data |
|
id: get-oracle-diag-data |
|
if: ${{ always() && steps.run-tests.outcome == 'failure' }} |
|
run: docker exec oracle bash -c "chmod -R +777 ./diag && cp -r ./diag /utPLSQL/database-diag" |
|
- name: Upload ORACLE_BASE/diag data Artifact |
|
id: upload |
|
if: ${{ always() && steps.run-tests.outcome == 'failure' }} |
|
uses: actions/upload-artifact@v4 |
|
with: |
|
name: my-artifact$-${{matrix.db_version_name}} |
|
path: ${{github.workspace}}/database-diag |
|
#End Needed to diagnose occasional failures of DB on test runs |
|
|
|
- name: Validate utPLSQL reports format |
|
id: validate-reports-format |
|
run: bash .github/scripts/validate_report_files.sh |
|
|
|
- name: Codecov |
|
uses: codecov/codecov-action@v4 |
|
with: |
|
token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos |
|
files: ./cobertura.xml |
|
flags: ${{matrix.db_version_name}} |
|
fail_ci_if_error: true # optional (default = false) |
|
|
|
- name: Publish unit test results |
|
uses: EnricoMi/publish-unit-test-result-action@v2 |
|
if: always() |
|
with: |
|
files: junit_test_results.xml |
|
|
|
- name: SonarCloud Scan |
|
id: sonar |
|
if: ${{ always() && matrix.run-sonar-scanner == true }} |
|
uses: SonarSource/sonarqube-scan-action@master |
|
env: |
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any |
|
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} |
|
with: |
|
args: > |
|
-Dsonar.buildString=${{ format( '{0}.{1}', env.UTPLSQL_BUILD_VERSION, matrix.id ) }} |
|
-Dsonar.plsql.jdbc.url=${{ format( 'jdbc:oracle:thin:@//localhost:1521/{0}', env.ORACLE_SID ) }} |
|
-Dsonar.plsql.jdbc.driver.path=${{ format( '{0}/ojdbc8.jar', env.OJDBC_HOME ) }} |
|
|
|
publish: |
|
name: Deploy documentation |
|
needs: [ build ] |
|
concurrency: publish |
|
runs-on: ubuntu-latest |
|
timeout-minutes: 30 |
|
env: |
|
API_TOKEN_GITHUB: ${{ secrets.API_TOKEN_GITHUB }} |
|
if: | |
|
github.repository == 'utPLSQL/utPLSQL' && |
|
github.base_ref == null && github.ref == 'refs/heads/develop' |
|
steps: |
|
- name: 🔍 API_TOKEN_GITHUB |
|
if: env.API_TOKEN_GITHUB == '' |
|
env: |
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
|
run: echo "API_TOKEN_GITHUB=${GITHUB_TOKEN}" >> $GITHUB_ENV |
|
- uses: actions/checkout@v4 |
|
with: |
|
fetch-depth: 0 |
|
token: ${{ env.API_TOKEN_GITHUB }} |
|
- uses: c-py/action-dotenv-to-setenv@v5 |
|
with: |
|
env-file: .github/variables/.env |
|
- uses: FranzDiebold/github-env-vars-action@v2.8.0 #https://github.com/marketplace/actions/github-environment-variables-action |
|
|
|
- name: Set buid version number env variables |
|
id: set-build-version-number-vars |
|
run: .github/scripts/set_version_numbers_env.sh |
|
|
|
- name: Update project version & build number in source code and documentation |
|
id: update-project-version |
|
run: .github/scripts/update_project_version.sh |
|
|
|
- name: Push version update to repository |
|
id: push-version-number-update |
|
run: | |
|
git add sonar-project.properties VERSION BUILD_NO source/* docs/* |
|
git commit -m 'Updated project version after build [skip ci]' |
|
git push --quiet origin HEAD:${CI_ACTION_REF_NAME} |
|
|
|
- name: Setup git config |
|
run: | |
|
git config --global user.email "github-actions[bot]@users.noreply.github.com" |
|
git config --global user.name "github-actions[bot]" |
|
|
|
- name: Build and publish documentation |
|
run: | |
|
pip install mkdocs |
|
pip install mkdocs-git-revision-date-localized-plugin |
|
pip install mkdocs-material |
|
pip install git+https://github.com/jimporter/mike.git |
|
mike deploy -p develop |
|
|
|
dispatch: |
|
name: Dispatch downstream builds |
|
concurrency: trigger |
|
needs: [ build, publish ] |
|
runs-on: ubuntu-latest |
|
timeout-minutes: 15 |
|
if: | |
|
github.repository == 'utPLSQL/utPLSQL' && github.base_ref == null && |
|
( startsWith( github.ref, 'refs/heads/release/v' ) || github.ref == 'refs/heads/develop' ) |
|
strategy: |
|
matrix: |
|
repo: [ 'utPLSQL/utPLSQL-demo-project', 'utPLSQL/utPLSQL-java-api' ] |
|
# repo: [ 'utPLSQL/utPLSQL-v2-v3-migration' ] |
|
steps: |
|
- name: Repository Dispatch |
|
uses: peter-evans/repository-dispatch@v4 |
|
with: |
|
token: ${{ secrets.API_TOKEN_GITHUB }} |
|
repository: ${{ matrix.repo }} |
|
event-type: utPLSQL-build |
|
|