From ac85c9c48939621be6b6ddccc0f0b5a729a340dd Mon Sep 17 00:00:00 2001 From: Juarez Rudsatz Date: Sun, 6 Apr 2025 20:33:58 -0300 Subject: [PATCH 01/10] chore: add python script for test connectioning to firebird --- test_connection.py | 56 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100755 test_connection.py diff --git a/test_connection.py b/test_connection.py new file mode 100755 index 0000000..cb175e7 --- /dev/null +++ b/test_connection.py @@ -0,0 +1,56 @@ +#!/usr/bin/env python3 +# coding: utf-8 + +import typer + +from firebird.driver import connect, DESCRIPTION_NAME +from rich import print +from rich.table import Table + +app = typer.Typer() + +# region Commands ---------------------------------------------------------------------- + + +@app.command() +def connect_to_firebird( + database: str, + host: str = "localhost", + user: str = "sysdba", + password: str = "masterkey", + query: str = None, +) -> int: + """Attach to an existing database/alias using server connection to host""" + # @ See: https://firebird-driver.readthedocs.io/en/stable/getting-started.html#executing-sql-statements + + tab = Table("Query Results") + db = f"{host}:{database}" + + with connect(db, user=user, password=password) as con: + with con.cursor() as cursor: + print(f"Connected to {db}") + cursor.execute(query or "SELECT * FROM rdb$roles") + + for fieldDesc in cursor.description: + tab.add_column(fieldDesc[DESCRIPTION_NAME]) + + fieldIndices = range(len(cursor.description)) + for row in cursor: + cols = [] + for fieldIndex in fieldIndices: + fieldValue = str(row[fieldIndex]) + cols += [fieldValue] + tab.add_row(*cols) + + print(tab) + return 0 + + +# endregion + +# region Main --------------------------------------------------------------------------- + +if __name__ == "__main__": + app() + +# endregion From d4ddde78707cb72848370a4e86fc6bab3e911ca6 Mon Sep 17 00:00:00 2001 From: Juarez Rudsatz Date: Sun, 6 Apr 2025 22:56:58 -0300 Subject: [PATCH 02/10] ci: only run github actions on master branch --- .github/workflows/testing_changes.yml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/.github/workflows/testing_changes.yml b/.github/workflows/testing_changes.yml index b3a3e2f..f21cdcb 100644 --- a/.github/workflows/testing_changes.yml +++ b/.github/workflows/testing_changes.yml @@ -4,12 +4,10 @@ name: testing_changes on: push: - branches-ignore: - - 'main' - - 'master' - - 'draft/*' + branches: [ "master" ] pull_request: - types: [opened, reopened, synchronize] + branches: [ "master" ] + types: [opened, reopened, synchronize, ready_for_review] release: types: [created, edited] workflow_dispatch: From 2af1a7330d5f7c973587027d6c2be269b527df0c Mon Sep 17 00:00:00 2001 From: Juarez Rudsatz Date: Tue, 8 Apr 2025 13:17:49 -0300 Subject: [PATCH 03/10] ci: added action workflow-info to report runner environment --- .github/actions/workflow-info/action.yaml | 63 +++++++++++++++++++++++ .github/workflows/testing_changes.yml | 13 ++++- 2 files changed, 74 insertions(+), 2 deletions(-) create mode 100644 .github/actions/workflow-info/action.yaml diff --git a/.github/actions/workflow-info/action.yaml b/.github/actions/workflow-info/action.yaml new file mode 100644 index 0000000..185b891 --- /dev/null +++ b/.github/actions/workflow-info/action.yaml @@ -0,0 +1,63 @@ +name: 'Report Workflow Information' +description: 'Reusable action meant to be used in workflow steps' +branding: + icon: 'watch' + color: 'green' + +inputs: + title: + description: 'A reference to put in the report title' + required: true + default: 'the Job' + parameters: + description: 'Input variables used in Job' + required: false + content: + description: 'Content to put in the report' + required: false +outputs: + status: + description: "Return report status" + value: ${{ steps.report_workflow_generation.outputs.status }} +runs: + using: "composite" + steps: + - name: Report Workflow Information + id: report_workflow_generation + env: + REPORT_PARAMS: '${{ inputs.parameters }}' + REPORT_CONTENT: '${{ inputs.content }}' + shell: bash + run: | + echo "::group::Generating report" + echo "status=started" >> "${GITHUB_OUTPUT}"; + + dump_ctx(){ + echo "::group::Context ${1:-Unknown}" + local text; + if ! text="$(cat -)"; then printf 'Failed to dump context for %s\n' "${1:-Unknown}" >> "${GITHUB_STEP_SUMMARY}"; fi + text="${text#"${text%%[![:space:]]*}"}" + if test "${#text}" -gt 3; then + printf '\n### %s Context\n\n\n```json\n%s\n```\n' "${1:-Unknown}" "${text:-Nothing in context}" >> "${GITHUB_STEP_SUMMARY}"; + fi + echo "::endgroup::"; + }; + + printf '# Workflow Information on ${{ inputs.title }}\n\n' >> "${GITHUB_STEP_SUMMARY}"; + printf '\n## Event Information\n\n' >> "${GITHUB_STEP_SUMMARY}"; + echo '- github.ref_name: ${{ github.ref_name }}' >> "${GITHUB_STEP_SUMMARY}"; + echo '- github.sha: ${{ github.sha }}' >> "${GITHUB_STEP_SUMMARY}"; + + echo "${REPORT_PARAMS:-}" | dump_ctx "Parameters"; + if test -n "${REPORT_CONTENT:-}"; then + printf '\n## Summary\n\n' >> "${GITHUB_STEP_SUMMARY}"; + echo "${REPORT_CONTENT:-}" >> "${GITHUB_STEP_SUMMARY}"; + fi + + printf '\n## Context Information\n' >> "${GITHUB_STEP_SUMMARY}"; + echo '${{ toJson(runner) }}' | dump_ctx "Runner"; + echo '${{ toJson(job) }}' | dump_ctx "Job"; + + echo "status=finished" >> "${GITHUB_OUTPUT}"; + echo "::endgroup::" + diff --git a/.github/workflows/testing_changes.yml b/.github/workflows/testing_changes.yml index f21cdcb..db0bef2 100644 --- a/.github/workflows/testing_changes.yml +++ b/.github/workflows/testing_changes.yml @@ -72,8 +72,17 @@ jobs: if: github.event_name != 'release' uses: actions/checkout@v3 - - name: Testing changes with FirebirdSQL version ${{ matrix.target }} on ${{ github.event_name }} triggered by '${{ github.sha }}' - if: github.event_name != 'release' + - name: Report Workflow Information + id: workflow_report + uses: ./.github/actions/workflow-info + with: + title: '${{ github.ref_name }}' + parameters: '${{ toJson(inputs) }}' + content: | + - Ref: ${{ github.head_ref }} + + - name: Testing changes with FirebirdSQL version ${{ matrix.target }} on ${{ matrix.os }} triggered by '${{ github.event_name }}' + if: github.event_name != 'release' && matrix.os == 'ubuntu-latest' uses: ./ # Uses an action in the root directory with: version: '${{ matrix.target }}' From 10c05fb2d3634fb40c4f4a1f378d81c4d2bdb598 Mon Sep 17 00:00:00 2001 From: Juarez Rudsatz Date: Sun, 6 Apr 2025 20:35:05 -0300 Subject: [PATCH 04/10] ci: also test in windows-latest macos-latest and macos-13-intel --- .github/workflows/testing_changes.yml | 68 +++++++++++++++++++++------ testing.sh | 4 +- 2 files changed, 56 insertions(+), 16 deletions(-) diff --git a/.github/workflows/testing_changes.yml b/.github/workflows/testing_changes.yml index db0bef2..88e2ddc 100644 --- a/.github/workflows/testing_changes.yml +++ b/.github/workflows/testing_changes.yml @@ -60,14 +60,27 @@ jobs: ci: name: ci-testing_changes strategy: - # max-parallel: 1 + fail-fast: false matrix: - target: [latest, 5, 5.0.2, 5-noble, 5-jammy, 4, 4.0.5, 3, 3.0.12] - os: [ "ubuntu-latest" ] - #TODO: os: [ "ubuntu-latest", "windows-latest", "macos-latest" ] + os: [ "ubuntu-latest", "windows-latest", "macos-latest", "macos-13" ] + # ubuntu-latest: https://github.com/actions/runner-images/blob/main/images/ubuntu/Ubuntu2404-Readme.md + # macos-latest: https://github.com/actions/runner-images/blob/main/images/macos/macos-15-arm64-Readme.md + # macos-13: https://github.com/actions/runner-images/blob/main/images/macos/macos-13-Readme.md + # windows-latest: https://github.com/actions/runner-images/blob/main/images/windows/Windows2022-Readme.md + target: [ 'latest', '5', '5.0.2', '5-noble', '5-jammy', '4', '4.0.5', '3', '3.0.12' ] + # https://github.com/FirebirdSQL/firebird-docker runs-on: "${{ matrix.os }}" steps: + - name: Testing release with FirebirdSQL version ${{ matrix.target }} triggered by version '${{ github.event.release.tag_name }}' + if: github.event_name == 'release' && matrix.os == 'ubuntu-latest' + uses: juarezr/firebirdsql-github-action@master + with: + version: '${{ matrix.target }}' + firebird_database: 'my_database.fdb' + firebird_user: 'my_user' + firebird_password: 'my_password' + - name: Checkout source code on event ${{ github.event_name }} triggered by '${{ github.sha }}' if: github.event_name != 'release' uses: actions/checkout@v3 @@ -90,24 +103,51 @@ jobs: firebird_user: 'my_user' firebird_password: 'my_password' - - name: Testing release with FirebirdSQL version ${{ matrix.target }} triggered by version '${{ github.event.release.tag_name }}' - if: github.event_name == 'release' - uses: juarezr/firebirdsql-github-action@master - with: - version: '${{ matrix.target }}' - firebird_database: 'my_database.fdb' - firebird_user: 'my_user' - firebird_password: 'my_password' + - name: Testing release with FirebirdSQL version ${{ matrix.target }} on '${{ matrix.os }}' + if: github.event_name != 'release' && matrix.os != 'ubuntu-latest' + shell: bash + run: | + export INPUT_CONTAINER_NAME='firebirdsql' + export INPUT_FIREBIRD_DATABASE='localhost:/var/lib/firebird/data/my_database.fdb' + export INPUT_FIREBIRD_USER='my_user' + export INPUT_FIREBIRD_PASSWORD='my_password' + export INPUT_FIREBIRD_CONF='ConnectionTimeout=180,DeadlockTimeout=10' + echo "::group::Checkout Report" + echo "PWD: ${PWD:-}" + ls --escape --dereference-command-line --human-readable --time-style=iso --no-group --color=auto -la + echo "::endgroup::" + bash entrypoint.sh - name: Install FirebirdSQL clients + if: matrix.os == 'ubuntu-latest' + shell: bash run: | sudo apt-get update sudo apt-get install -y --no-install-recommends firebird3.0-utils libfbclient2 - - name: Testing Connection and Query to ${{ matrix.target }} + - name: Wait for Firebird version ${{ matrix.target }} to be available on ${{ matrix.os }} + if: matrix.os == 'ubuntu-latest' + shell: bash run: | for i in {0..120} ; do nc -z localhost 3050 && echo "Up: ${i} secs" && break; sleep 1; done - echo 'select * from rdb$database;' | isql-fb -bail -quiet -z -user my_user -password my_password 'localhost:/var/lib/firebird/data/my_database.fdb' + + - name: Testing Connection and Query with FirebirdSQL version ${{ matrix.target }} + if: matrix.os == 'ubuntu-latest' + shell: bash + run: | + echo 'SELECT * FROM rdb$roles;' | isql-fb -bail -quiet -z -user my_user -password my_password 'localhost:/var/lib/firebird/data/my_database.fdb' + + - name: Install Python driver + shell: bash + run: | + python3 -m pip install --upgrade pip wheel + python3 -m pip install firebird-driver + python3 -m pip install rich typer + + - name: Testing Connection and Query with FirebirdSQL version ${{ matrix.target }} with python + shell: bash + run: | + python3 test_connection.py --user my_user --password my_password --host localhost /var/lib/firebird/data/my_database.fdb - name: Stop Container run: | diff --git a/testing.sh b/testing.sh index fcd8494..19b8d5b 100755 --- a/testing.sh +++ b/testing.sh @@ -65,11 +65,11 @@ for INPUT_VERSION in latest 5 5.0.2 5-noble 5-jammy 4 4.0.5 3 3.0.12; do msg "Querying the FirebirdSQL server inside the docker container at [${IP_ADDRESS}]..." # shellcheck disable=SC2016 - if ! echo 'SELECT * FROM rdb$database;' | + if ! echo 'SELECT * FROM rdb$roles;' | docker run -i --rm --name "${INPUT_CONTAINER_NAME}-client2" \ --network "${INPUT_NETWORK_NAME}" --env IP_ADDRESS="${IP_ADDRESS}" \ "firebirdsql/firebird:${INPUT_VERSION:-}" \ - sh -c isql -bail -quiet -echo -merge -m2 -z \ + sh -c isql -bail -quiet -z \ -user "${INPUT_FIREBIRD_USER}" -password "${INPUT_FIREBIRD_PASSWORD}" \ "${IP_ADDRESS}:${FIREBIRD_DATA}/${INPUT_FIREBIRD_DATABASE}" | ident; then From ee24ba96437cb331e1b0ce5963aa3c8698fe1794 Mon Sep 17 00:00:00 2001 From: Juarez Rudsatz Date: Tue, 8 Apr 2025 11:35:27 -0300 Subject: [PATCH 05/10] ci: setup docker on MacOs --- .github/workflows/testing_changes.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/.github/workflows/testing_changes.yml b/.github/workflows/testing_changes.yml index 88e2ddc..3bfc8fe 100644 --- a/.github/workflows/testing_changes.yml +++ b/.github/workflows/testing_changes.yml @@ -94,6 +94,21 @@ jobs: content: | - Ref: ${{ github.head_ref }} + - name: Setup docker (missing on MacOS) on ${{ matrix.os }} + if: runner.os == 'macos' + uses: docker-practice/actions-setup-docker@master + timeout-minutes: 12 + + - name: Report Docker Information on ${{ matrix.os }} + shell: bash + run: | + echo "::group::Step Report" + printf '## Docker Version on ${{ matrix.os }}\n\n' >> "${GITHUB_STEP_SUMMARY}"; + docker --version >> "${GITHUB_STEP_SUMMARY}"; + printf '## Docker Configuration on ${{ matrix.os }}\n\n' >> "${GITHUB_STEP_SUMMARY}"; + docker version >> "${GITHUB_STEP_SUMMARY}"; + echo "::endgroup::" + - name: Testing changes with FirebirdSQL version ${{ matrix.target }} on ${{ matrix.os }} triggered by '${{ github.event_name }}' if: github.event_name != 'release' && matrix.os == 'ubuntu-latest' uses: ./ # Uses an action in the root directory From 522b7d7918a0d2e5d294d61ef52091cbecb7a596 Mon Sep 17 00:00:00 2001 From: Juarez Rudsatz Date: Tue, 8 Apr 2025 13:50:35 -0300 Subject: [PATCH 06/10] fix typo --- .github/workflows/testing_changes.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/testing_changes.yml b/.github/workflows/testing_changes.yml index 3bfc8fe..992a0ed 100644 --- a/.github/workflows/testing_changes.yml +++ b/.github/workflows/testing_changes.yml @@ -118,7 +118,7 @@ jobs: firebird_user: 'my_user' firebird_password: 'my_password' - - name: Testing release with FirebirdSQL version ${{ matrix.target }} on '${{ matrix.os }}' + - name: Testing changes with FirebirdSQL version ${{ matrix.target }} on '${{ matrix.os }}' if: github.event_name != 'release' && matrix.os != 'ubuntu-latest' shell: bash run: | From 6242ceb813ff4c00a295322c6347cbdc13b1bec9 Mon Sep 17 00:00:00 2001 From: Juarez Rudsatz Date: Tue, 8 Apr 2025 14:19:07 -0300 Subject: [PATCH 07/10] ci test -SwitchLinuxEngine --- .github/workflows/testing_changes.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.github/workflows/testing_changes.yml b/.github/workflows/testing_changes.yml index 992a0ed..12e6f27 100644 --- a/.github/workflows/testing_changes.yml +++ b/.github/workflows/testing_changes.yml @@ -118,6 +118,18 @@ jobs: firebird_user: 'my_user' firebird_password: 'my_password' + - name: Switch to Linux Containers on '${{ matrix.os }}' + if: github.event_name != 'release' && matrix.os == 'windows-latest' + shell: bash + run: | + docker --help + command -v dockercli || true + command -v DockerCli || true + command -v DockerCli.exe || true + ls -l "C:\Program Files\Docker\Docker" + cd "C:\Program Files\Docker\Docker" + ./DockerCli.exe -SwitchLinuxEngine + - name: Testing changes with FirebirdSQL version ${{ matrix.target }} on '${{ matrix.os }}' if: github.event_name != 'release' && matrix.os != 'ubuntu-latest' shell: bash From c5525dc2bee0f1bfc9c48ea7643bf79eb58e0241 Mon Sep 17 00:00:00 2001 From: Juarez Rudsatz Date: Tue, 8 Apr 2025 14:21:27 -0300 Subject: [PATCH 08/10] win again --- .github/workflows/testing_changes.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/testing_changes.yml b/.github/workflows/testing_changes.yml index 12e6f27..2d4a8d3 100644 --- a/.github/workflows/testing_changes.yml +++ b/.github/workflows/testing_changes.yml @@ -123,6 +123,8 @@ jobs: shell: bash run: | docker --help + pwd + command -v docker || true command -v dockercli || true command -v DockerCli || true command -v DockerCli.exe || true From eced686ba4dd55256790778dcb2156a3446b1967 Mon Sep 17 00:00:00 2001 From: Juarez Rudsatz Date: Tue, 8 Apr 2025 14:26:21 -0300 Subject: [PATCH 09/10] again --- .github/workflows/testing_changes.yml | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/workflows/testing_changes.yml b/.github/workflows/testing_changes.yml index 2d4a8d3..70fe9cb 100644 --- a/.github/workflows/testing_changes.yml +++ b/.github/workflows/testing_changes.yml @@ -123,14 +123,17 @@ jobs: shell: bash run: | docker --help - pwd command -v docker || true command -v dockercli || true command -v DockerCli || true command -v DockerCli.exe || true - ls -l "C:\Program Files\Docker\Docker" - cd "C:\Program Files\Docker\Docker" - ./DockerCli.exe -SwitchLinuxEngine + pwd + ls -l "/c/" + ls -l "/c/Program Files" + ls -l "/c/Program Files/Docker" + ls -l "/c/Program Files/Docker/Docker" + # cd "C:\Program Files\Docker\Docker" + DockerCli.exe -SwitchLinuxEngine - name: Testing changes with FirebirdSQL version ${{ matrix.target }} on '${{ matrix.os }}' if: github.event_name != 'release' && matrix.os != 'ubuntu-latest' From 2b59db58ed1ae3cbbb26ca3a46b749e5e8aa3fb7 Mon Sep 17 00:00:00 2001 From: Juarez Rudsatz Date: Tue, 8 Apr 2025 14:30:11 -0300 Subject: [PATCH 10/10] sys --- .github/workflows/testing_changes.yml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/workflows/testing_changes.yml b/.github/workflows/testing_changes.yml index 70fe9cb..d153dc7 100644 --- a/.github/workflows/testing_changes.yml +++ b/.github/workflows/testing_changes.yml @@ -129,11 +129,8 @@ jobs: command -v DockerCli.exe || true pwd ls -l "/c/" - ls -l "/c/Program Files" - ls -l "/c/Program Files/Docker" - ls -l "/c/Program Files/Docker/Docker" - # cd "C:\Program Files\Docker\Docker" - DockerCli.exe -SwitchLinuxEngine + ls -l /c/Windows/system32/Do* + /c/Windows/system32/DockerCli.exe -SwitchLinuxEngine - name: Testing changes with FirebirdSQL version ${{ matrix.target }} on '${{ matrix.os }}' if: github.event_name != 'release' && matrix.os != 'ubuntu-latest'