From c6ac54812a4f253529858f7f41cc91ccf1fbaae6 Mon Sep 17 00:00:00 2001 From: Omkar P <45419097+omkar-foss@users.noreply.github.com> Date: Mon, 30 Sep 2024 08:51:19 +0530 Subject: [PATCH 1/2] Use official SQL Server docker image for tests (#7205) * Use official SQL Server docker image for tests * Try with tag 2019-latest instead of latest * Use platform ubuntu-20.04 for SQL Server * Switch to 2019-CU18-ubuntu-20.04 * Check with 2022-latest image tag and ubuntu-latest platform * Update health-cmd * Try sqlcmd without -N -C * Re-include -N -C, try with ubuntu-20.04 * Try ubuntu-20.04 without -N -C (last trial) * Finalize working config * Remove unused env variables --- .github/workflows/tests.yml | 12 +++++------- tests/compose.yml | 7 ++----- tests/tests_all.sh | 2 +- tests/tests_test.go | 2 +- 4 files changed, 9 insertions(+), 14 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 0601f006..24eab55a 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -176,17 +176,15 @@ jobs: services: mssql: - image: mcmoe/mssqldocker:latest + image: mcr.microsoft.com/mssql/server:2022-latest env: + TZ: Asia/Shanghai ACCEPT_EULA: Y - SA_PASSWORD: LoremIpsum86 - MSSQL_DB: gorm - MSSQL_USER: gorm - MSSQL_PASSWORD: LoremIpsum86 + MSSQL_SA_PASSWORD: LoremIpsum86 ports: - 9930:1433 options: >- - --health-cmd="/opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P LoremIpsum86 -l 30 -Q \"SELECT 1\" || exit 1" + --health-cmd="/opt/mssql-tools18/bin/sqlcmd -S localhost -U sa -P ${MSSQL_SA_PASSWORD} -N -C -l 30 -Q \"SELECT 1\" || exit 1" --health-start-period 10s --health-interval 10s --health-timeout 5s @@ -208,7 +206,7 @@ jobs: key: ${{ runner.os }}-go-${{ matrix.go }}-${{ hashFiles('tests/go.mod') }} - name: Tests - run: GITHUB_ACTION=true GORM_DIALECT=sqlserver GORM_DSN="sqlserver://gorm:LoremIpsum86@localhost:9930?database=gorm" ./tests/tests_all.sh + run: GITHUB_ACTION=true GORM_DIALECT=sqlserver GORM_DSN="sqlserver://sa:LoremIpsum86@localhost:9930?database=master" ./tests/tests_all.sh tidb: strategy: diff --git a/tests/compose.yml b/tests/compose.yml index 666b1fb0..66f2daee 100644 --- a/tests/compose.yml +++ b/tests/compose.yml @@ -18,16 +18,13 @@ services: - POSTGRES_USER=gorm - POSTGRES_PASSWORD=gorm mssql: - image: '${MSSQL_IMAGE:-mcmoe/mssqldocker}:latest' + image: '${MSSQL_IMAGE}:2022-latest' ports: - "127.0.0.1:9930:1433" environment: - TZ=Asia/Shanghai - ACCEPT_EULA=Y - - SA_PASSWORD=LoremIpsum86 - - MSSQL_DB=gorm - - MSSQL_USER=gorm - - MSSQL_PASSWORD=LoremIpsum86 + - MSSQL_SA_PASSWORD=LoremIpsum86 tidb: image: 'pingcap/tidb:v6.5.0' ports: diff --git a/tests/tests_all.sh b/tests/tests_all.sh index 0622f934..67c6938e 100755 --- a/tests/tests_all.sh +++ b/tests/tests_all.sh @@ -27,7 +27,7 @@ if [[ -z $GITHUB_ACTION ]]; then SQLCMDPASSWORD=LoremIpsum86 sqlcmd -U sa -S localhost:9930 -Q "IF SUSER_ID (N'gorm') IS NULL CREATE LOGIN gorm WITH PASSWORD = 'LoremIpsum86';" > /dev/null || true SQLCMDPASSWORD=LoremIpsum86 sqlcmd -U sa -S localhost:9930 -Q "IF USER_ID (N'gorm') IS NULL CREATE USER gorm FROM LOGIN gorm; ALTER SERVER ROLE sysadmin ADD MEMBER [gorm];" > /dev/null || true else - docker compose up -d + MSSQL_IMAGE=mcr.microsoft.com/mssql/server docker compose up -d fi cd .. fi diff --git a/tests/tests_test.go b/tests/tests_test.go index a127734e..e84162cd 100644 --- a/tests/tests_test.go +++ b/tests/tests_test.go @@ -20,7 +20,7 @@ var DB *gorm.DB var ( mysqlDSN = "gorm:gorm@tcp(localhost:9910)/gorm?charset=utf8&parseTime=True&loc=Local" postgresDSN = "user=gorm password=gorm dbname=gorm host=localhost port=9920 sslmode=disable TimeZone=Asia/Shanghai" - sqlserverDSN = "sqlserver://gorm:LoremIpsum86@localhost:9930?database=gorm" + sqlserverDSN = "sqlserver://sa:LoremIpsum86@localhost:9930?database=master" tidbDSN = "root:@tcp(localhost:9940)/test?charset=utf8&parseTime=True&loc=Local" ) From 62bd0b9331b8b191e5c1177c665d608603d9b802 Mon Sep 17 00:00:00 2001 From: Yidi Sprei Date: Mon, 30 Sep 2024 02:18:13 -0400 Subject: [PATCH 2/2] Add GitHub Actions workflow to automate release creation on tagged pushes (#7209) * feat(workflows): add GitHub Action to create release on new tag This workflow automates the release creation process whenever a new tag is pushed to the repository. It checks if a release for the tag already exists and creates one if it doesn't, enhancing the release management and streamlining the deployment process. * test * fix(workflow): improve release existence check in release-on-tag.yml Refactor the script to improve checking for existing releases by tag. Return an object instead of using core.setOutput to streamline the workflow logic. Also, set result-encoding to string for better compatibility. * fix(workflow): correct output handling in release-on-tag.yml Corrected the output handling in the 'release-on-tag.yml' workflow file by changing 'result-encoding' to 'outputs'. This ensures that the step correctly checks if a release exists before attempting to create a new one, thereby avoiding potential errors during the release process. Added a blank line for better readability. * fix(workflow): correct output setting in release-on-tag workflow Refactored how the release_exists output is set to be compatible with GitHub Actions syntax. This ensures the workflow reliably detects if a release already exists, improving the robustness of the release process. * fix(release): correct output handling in release-on-tag workflow Improved the way outputs are managed in the 'check_release' step by returning values instead of direct assignments. This change ensures better handling of release existence checks and improves code readability. Added 'result-encoding' to specify string encoding for results. * fix(workflow): correct release existence check and add debug output Refactored the release existence check to return a simple boolean string ('true'/'false') rather than an object. Added a step to print the release existence status for debugging purposes. This ensures correct conditional evaluation and aids in troubleshooting workflow issues. * fix(workflow): simplify release process by removing redundant checks The release-on-tag workflow has been streamlined by eliminating the redundant steps checking for existing releases. This change reduces complexity and speeds up the release process by directly creating a release on every tag push without prior existence verification. --- .github/workflows/release-on-tag.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 .github/workflows/release-on-tag.yml diff --git a/.github/workflows/release-on-tag.yml b/.github/workflows/release-on-tag.yml new file mode 100644 index 00000000..3868a8f5 --- /dev/null +++ b/.github/workflows/release-on-tag.yml @@ -0,0 +1,23 @@ +name: Create Release on Tag + +on: + push: + tags: + - '*' + +jobs: + create_release: + runs-on: ubuntu-latest + + steps: + - name: Create Release + uses: actions/create-release@v1 + with: + tag_name: ${{ github.ref_name }} + release_name: ${{ github.ref_name }} + body: | + Release ${{ github.ref_name }} of GORM. + draft: false + prerelease: false + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}