Skip to content

Commit

Permalink
Refactor to template-go
Browse files Browse the repository at this point in the history
  • Loading branch information
docktermj committed Feb 27, 2025
1 parent 2f0a8ae commit 5ac0232
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 18 deletions.
24 changes: 17 additions & 7 deletions .github/workflows/go-test-darwin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,19 @@ name: Go test darwin
on: [pull_request, workflow_dispatch]

env:
DYLD_LIBRARY_PATH: /opt/senzing/er/lib:/opt/senzing/er/lib/macos
LD_LIBRARY_PATH: /opt/senzing/er/lib:/opt/senzing/er/lib/macos
SENZING_LOG_LEVEL: TRACE
SENZING_TOOLS_DATABASE_URL: sqlite3://na:na@nowhere/tmp/sqlite/G2C.db

permissions:
contents: read

jobs:
go-test-darwin:
name: "Go test with Senzing: ${{ matrix.senzingsdk-version }}; OS: ${{ matrix.os }}; Go: ${{ matrix.go }}"
runs-on: ${{ matrix.os }}
name: "Go test with Senzing: ${{ matrix.senzingsdk-version }}; OS: macos-latest; Go: ${{ matrix.go }}"
runs-on: macos-latest
strategy:
matrix:
go: ["1.21"]
os: [macos-latest]
senzingsdk-version: [staging-v4]

steps:
Expand All @@ -41,14 +39,26 @@ jobs:
with:
senzingsdk-repository-path: ${{ secrets.SENZING_OSX_BETA_REPOSITORY }}

- name: Set environment variables
run: |
SENZING_PATH="${HOME}/senzing"
{
echo "SENZING_PATH=${SENZING_PATH}"
echo "LD_LIBRARY_PATH=${SENZING_PATH}/er/lib:${SENZING_PATH}/er/lib/macos"
echo "DYLD_LIBRARY_PATH=${SENZING_PATH}/er/lib:${SENZING_PATH}/er/lib/macos"
echo "SENZING_DATA_DIR=${SENZING_PATH}/er/data"
echo CGO_CFLAGS="-g -I${SENZING_PATH}/er/sdk/c"
echo CGO_LDFLAGS="-L${SENZING_PATH}/er/lib -lSz -Wl,-no_warn_duplicate_libraries"
} >> "$GITHUB_ENV"
- name: Copy /etc files
run: sudo mkdir -p /opt/senzing/er/etc && sudo cp testdata/senzing-license/g2.lic /opt/senzing/er/etc/g2.lic
run: sudo mkdir -p "${SENZING_PATH}/etc" && sudo cp testdata/senzing-license/g2.lic "${SENZING_PATH}/er/etc/g2.lic"

- name: Copy test database files
run: mkdir -p /tmp/sqlite && cp testdata/sqlite/G2C.db /tmp/sqlite/

- name: Run go test
run: go test -exec /Users/runner/work/serve-chat/serve-chat/bin/macos_exec_dyld.sh -json -v -p 1 -coverprofile=./cover.out -covermode=atomic -coverpkg=./... ./... 2>&1 | tee /tmp/gotest.log | gotestfmt
run: go test -exec "${GITHUB_WORKSPACE}/bin/macos_exec_dyld.sh" -json -v -p 1 -coverprofile=./cover.out -covermode=atomic -coverpkg=./... ./... 2>&1 | tee /tmp/gotest.log | gotestfmt

- name: Store coverage file
uses: actions/upload-artifact@v4
Expand Down
11 changes: 7 additions & 4 deletions .github/workflows/go-test-linux.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ name: Go test linux
on: [push]

env:
LD_LIBRARY_PATH: /opt/senzing/er/lib
SENZING_LOG_LEVEL: TRACE
SENZING_TOOLS_DATABASE_URL: sqlite3://na:na@nowhere/tmp/sqlite/G2C.db

Expand All @@ -12,12 +11,13 @@ permissions:

jobs:
go-test-linux:
name: "Go test with OS: ${{ matrix.os }}; Go: ${{ matrix.go }}"
name: "Go test with Senzing: ${{ matrix.senzingsdk-version }}; OS: ${{ matrix.os }}; Go: ${{ matrix.go }}"
runs-on: ${{ matrix.os }}
strategy:
matrix:
go: ["1.21"]
os: [ubuntu-latest]
senzingsdk-version: [staging-v4]

steps:
- name: Checkout repository
Expand Down Expand Up @@ -45,10 +45,13 @@ jobs:
run: sudo mkdir -p /etc/opt/senzing && sudo cp testdata/senzing-license/g2.lic /etc/opt/senzing/g2.lic

- name: Copy test database files
run: mkdir -p /tmp/sqlite && cp testdata/sqlite/G2C.db /tmp/sqlite/G2C.db
run: mkdir -p /tmp/sqlite && cp testdata/sqlite/G2C.db /tmp/sqlite/

- name: Run go test
run: go test -json -v -p 1 -coverprofile=./cover.out -covermode=atomic -coverpkg=./... ./... 2>&1 | tee /tmp/gotest.log | gotestfmt
run: |
export SENZING_PATH="/opt/senzing"
export LD_LIBRARY_PATH="${SENZING_PATH}/er/lib:${SENZING_PATH}/er/lib/macos"
go test -json -v -p 1 -coverprofile=./cover.out -covermode=atomic -coverpkg=./... ./... 2>&1 | tee /tmp/gotest.log | gotestfmt
- name: Store coverage file
uses: actions/upload-artifact@v4
Expand Down
15 changes: 8 additions & 7 deletions .github/workflows/go-test-windows.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@ name: Go test windows
on: [pull_request, workflow_dispatch]

env:
SENZING_LOG_LEVEL: TRACE
SENZING_TOOLS_DATABASE_URL: "sqlite3://na:na@nowhere/C:\\Temp\\sqlite\\G2C.db"

permissions:
contents: read

jobs:
go-test-windows:
name: "Go test with Senzing: ${{ matrix.senzingsdk-version }}; OS: ${{ matrix.os }}; Go: ${{ matrix.go }}"
runs-on: ${{ matrix.os }}
name: "Go test with Senzing: ${{ matrix.senzingsdk-version }}; OS: windows-latest; Go: ${{ matrix.go }}"
runs-on: windows-latest
strategy:
matrix:
go: ["1.21"]
os: [windows-latest]
senzingsdk-version: [staging-v4]

steps:
Expand All @@ -40,18 +40,19 @@ jobs:
senzingsdk-repository-path: ${{ secrets.SENZING_WIN_BETA_REPOSITORY }}

- name: Add to "Path" environment variable
run: |
# shellcheck disable=SC2028
echo "C:\Program Files\Senzing\er\lib" >> "$env:GITHUB_PATH"
run: Add-Content "$env:GITHUB_PATH" "$Env:USERPROFILE\Senzing\er\lib"

- name: Copy /etc files
run: copy testdata/senzing-license/g2.lic "C:\Program Files\Senzing\er\etc\g2.lic"
run: copy testdata/senzing-license/g2.lic "$Env:USERPROFILE\Senzing\er\etc\g2.lic"

- name: Copy test database files
run: mkdir "C:\Temp\sqlite" && copy testdata/sqlite/G2C.db "C:\Temp\sqlite\G2C.db"

- name: Run go test
run: |
$Env:SENZING_PATH = "$Env:USERPROFILE\Senzing"
$Env:CGO_CFLAGS = "-g -I$Env:SENZING_PATH\er\sdk\c"
$Env:CGO_LDFLAGS = "-L$Env:SENZING_PATH\er\lib -lSz"
go test -json -v -p 1 -coverprofile=cover -covermode=atomic -coverpkg=./... ./... 2>&1 | tee "C:\Temp\gotest.log" | gotestfmt
cp cover cover.out
Expand Down

0 comments on commit 5ac0232

Please sign in to comment.