Add GitHub action to run tests #3
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Run Tests | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
env: | |
GORM_ORACLEDB_USER: ${{ secrets.GORM_ORACLEDB_USER }} | |
GORM_ORACLEDB_PASSWORD: ${{ secrets.GORM_ORACLEDB_PASSWORD }} | |
GORM_ORACLEDB_CONNECTSTRING: ${{ secrets.GORM_ORACLEDB_CONNECTSTRING }} | |
GORM_ORACLEDB_LIBDIR: /home/runner/work/_temp/instantclient_23_9 | |
services: | |
oracle: | |
image: gvenzl/oracle-free:latest | |
env: | |
APP_USER: $GORM_ORACLEDB_USER | |
APP_USER_PASSWORD: $GORM_ORACLEDB_PASSWORD | |
ORACLE_RANDOM_PASSWORD: yes | |
ports: | |
- 1521:1521 | |
options: >- | |
--health-cmd="sqlplus -s $GORM_ORACLEDB_USER/$GORM_ORACLEDB_PASSWORD@localhost:1521/FREEPDB1 <<< \"select 1 from dual;\"" | |
--health-start-period 10s | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 10 | |
steps: | |
- name: Set up Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: '1.24.4' | |
- name: Install Oracle Instant Client | |
run: | | |
cd $RUNNER_TEMP | |
# Download the desired Oracle Instant Client zip files | |
curl -sSfLO "https://download.oracle.com/otn_software/linux/instantclient/2390000/instantclient-basic-linux.x64-23.9.0.25.07.zip" | |
# Unzip the packages into a single directory | |
unzip -q -o "instantclient-basic-linux.x64-23.9.0.25.07.zip" | |
# Install the operating system libaio package | |
sudo ln -s /usr/lib/x86_64-linux-gnu/libaio.so.1t64 /usr/lib/libaio.so.1 | |
# Update the runtime link path | |
echo "/home/runner/work/_temp/instantclient_23_9" | sudo tee /etc/ld.so.conf.d/oracle-instantclient.conf | |
sudo ldconfig | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Run all tests under tests directory | |
run: | | |
cd tests | |
go get -t github.com/oracle-samples/gorm-oracle/tests | |
go get . | |
go test -v |