diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4cb3d7b79f..90e77aa936 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -30,6 +30,8 @@ jobs: GOFLAGS: -mod=readonly steps: - uses: actions/checkout@v3 + with: + fetch-depth: 0 - uses: actions/setup-go@v3 with: { go-version: "${{ env.GO_VERSION }}" } - name: "Copy language files" @@ -38,9 +40,6 @@ jobs: - name: "Unit" working-directory: server run: make test.unit - - name: "Store" - working-directory: server - run: make test.store - name: "Integration" working-directory: server run: make test.integration @@ -52,6 +51,8 @@ jobs: runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v3 + with: + fetch-depth: 0 - uses: actions/setup-node@v3 with: { node-version: "${{ env.NODE_VERSION }}" } - uses: actions/cache@v3 @@ -89,6 +90,8 @@ jobs: steps: - run: echo "BUILD_VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV - uses: actions/checkout@v3 + with: + fetch-depth: 0 - uses: actions/setup-go@v3 with: { go-version: "${{ env.GO_VERSION }}" } - name: "Restore web console dist from cache" @@ -120,6 +123,8 @@ jobs: lib: [ "js", "vue" ] steps: - uses: actions/checkout@v3 + with: + fetch-depth: 0 - uses: actions/setup-node@v3 with: { node-version: "${{ env.NODE_VERSION }}" } - uses: actions/cache@v3 @@ -146,6 +151,8 @@ jobs: lib: [ "js", "vue" ] steps: - uses: actions/checkout@v3 + with: + fetch-depth: 0 - uses: actions/setup-node@v3 with: registry-url: 'https://registry.npmjs.org/' @@ -190,6 +197,8 @@ jobs: needs: [ "lib-build-and-publish" ] steps: - uses: actions/checkout@v3 + with: + fetch-depth: 0 - uses: actions/setup-node@v3 with: { node-version: "${{ env.NODE_VERSION }}" } - name: "Setup YARN" @@ -223,6 +232,8 @@ jobs: steps: - run: echo "BUILD_VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV - uses: actions/checkout@v3 + with: + fetch-depth: 0 - uses: actions/setup-node@v3 with: { node-version: "${{ env.NODE_VERSION }}" } - name: "Setup YARN" @@ -261,6 +272,8 @@ jobs: RELEASE_SFTP_URI: ${{ secrets.RELEASE_SFTP_URI }} steps: - uses: actions/checkout@v3 + with: + fetch-depth: 0 - run: echo "BUILD_VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV - name: "Prepare dist dir" run: | @@ -334,6 +347,8 @@ jobs: steps: - run: echo "BUILD_VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV - uses: actions/checkout@v3 + with: + fetch-depth: 0 - name: "Download" run: | curl --silent --location "${{ env.RELEASE_BASE_URL }}/corteza-server-${{ env.BUILD_VERSION }}-${{ matrix.os }}-amd64.tar.gz" | \ @@ -384,6 +399,8 @@ jobs: steps: - run: echo "BUILD_VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV - uses: actions/checkout@v3 + with: + fetch-depth: 0 - uses: actions/setup-go@v3 with: { go-version: "${{ env.GO_VERSION }}" } - name: "Copy essentials" @@ -419,6 +436,8 @@ jobs: steps: - uses: actions/checkout@v3 + with: + fetch-depth: 0 - name: "Parse version tag" id: version run: | @@ -469,6 +488,8 @@ jobs: needs: [ docker-images, release ] steps: - uses: actions/checkout@v3 + with: + fetch-depth: 0 - name: "Parse version tag" id: version run: | @@ -503,6 +524,8 @@ jobs: needs: [ notify ] steps: - uses: actions/checkout@v3 + with: + fetch-depth: 0 - name: Create Sentry release uses: getsentry/action-release@v1 diff --git a/.github/workflows/test-e2e.yml b/.github/workflows/test-e2e.yml index b3ff5e000d..180e1bdeed 100644 --- a/.github/workflows/test-e2e.yml +++ b/.github/workflows/test-e2e.yml @@ -92,6 +92,7 @@ jobs: - name: Checkout corteza repo uses: actions/checkout@v3 with: + fetch-depth: 0 path: corteza token: ${{ secrets.GITHUB_TOKEN }} ref: ${{ github.ref_name }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2043a0e973..6b5c130436 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -32,6 +32,8 @@ jobs: lib: [ "js", "vue" ] steps: - uses: actions/checkout@v3 + with: + fetch-depth: 0 - uses: actions/setup-node@v3 with: { node-version: "${{ env.NODE_VERSION }}" } - uses: actions/cache@v3 @@ -56,6 +58,8 @@ jobs: matrix: { app: [ admin, compose, discovery, privacy, reporter, one, workflow ] } steps: - uses: actions/checkout@v3 + with: + fetch-depth: 0 - uses: actions/setup-node@v3 with: { node-version: "${{ env.NODE_VERSION }}" } - name: "Setup YARN" @@ -80,23 +84,96 @@ jobs: runs-on: ubuntu-22.04 env: GOFLAGS: -mod=readonly + services: + postgres: + image: postgres:15 + env: + POSTGRES_USER: corteza + POSTGRES_PASSWORD: corteza + POSTGRES_DB: corteza_test + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + ports: + - 5432:5432 + mysql: + image: mysql:8.0 + env: + MYSQL_ROOT_PASSWORD: corteza + MYSQL_DATABASE: corteza_test + MYSQL_USER: corteza + MYSQL_PASSWORD: corteza + options: >- + --health-cmd="mysqladmin ping" + --health-interval=10s + --health-timeout=5s + --health-retries=3 + ports: + - 3306:3306 + sqlserver: + image: mcr.microsoft.com/mssql/server:2019-latest + env: + SA_PASSWORD: Corteza123! + ACCEPT_EULA: Y + MSSQL_PID: Express + options: >- + --health-cmd="/opt/mssql-tools18/bin/sqlcmd -S localhost -U sa -P Corteza123! -C -Q 'SELECT 1'" + --health-interval=15s + --health-timeout=10s + --health-retries=5 + ports: + - 1433:1433 steps: - uses: actions/checkout@v3 + with: + fetch-depth: 0 - uses: actions/setup-go@v3 with: { go-version: "${{ env.GO_VERSION }}" } - name: "Copy language files" working-directory: server/pkg/locale run: make src/en + - name: "Wait for databases" + run: | + # Wait a bit longer for SQL Server to fully initialize + sleep 30 + # Test connections (wait for all databases to be ready) + until docker exec $(docker ps -qf "ancestor=postgres:15") pg_isready; do sleep 1; done + until docker exec $(docker ps -qf "ancestor=mysql:8.0") mysqladmin ping -h localhost --silent; do sleep 1; done + until docker exec $(docker ps -qf "ancestor=mcr.microsoft.com/mssql/server:2019-latest") /opt/mssql-tools18/bin/sqlcmd -S localhost -U sa -P 'Corteza123!' -C -Q 'SELECT 1'; do sleep 1; done + - name: "Create SQL Server test database" + run: | + # Create the corteza_test database in SQL Server + docker exec $(docker ps -qf "ancestor=mcr.microsoft.com/mssql/server:2019-latest") /opt/mssql-tools18/bin/sqlcmd -S localhost -U sa -P 'Corteza123!' -C -Q 'CREATE DATABASE corteza_test;' - name: "Unit" working-directory: server run: make test.unit - - name: "Store" + - name: "Store - SQLite" + working-directory: server + env: + RDBMS_SQLITE_DSN: "sqlite3://file::memory:?cache=shared&mode=memory" + run: go test -v ./store/tests/... -run Test_RDBMS_SQLITE + - name: "Store - PostgreSQL" working-directory: server - run: make test.store + env: + RDBMS_PGSQL_DSN: "postgres://corteza:corteza@localhost:5432/corteza_test?sslmode=disable" + run: go test -v ./store/tests/... -run Test_RDBMS_PGSQL + - name: "Store - MySQL" + working-directory: server + env: + RDBMS_MYSQL_DSN: "mysql://corteza:corteza@tcp(localhost:3306)/corteza_test" + run: go test -v ./store/tests/... -run Test_RDBMS_MYSQL + - name: "Store - SQL Server 2019" + working-directory: server + env: + RDBMS_SQLSERVER_2019_DSN: "sqlserver://sa:Corteza123!@localhost:1433?database=corteza_test" + run: go test -v ./store/tests/... -run Test_RDBMS_SQLSERVER_2019 - name: "Integration" working-directory: server run: make test.integration + notify: if: failure() name: "Send matrix testing notification" diff --git a/server/store/tests/main_test.go b/server/store/tests/main_test.go index 2424722b2a..c4f7a80552 100644 --- a/server/store/tests/main_test.go +++ b/server/store/tests/main_test.go @@ -6,6 +6,8 @@ import ( "testing" "time" + "github.com/cortezaproject/corteza/server/pkg/cli" + "github.com/cortezaproject/corteza/server/pkg/id" "github.com/cortezaproject/corteza/server/store" "github.com/cortezaproject/corteza/server/store/adapters/rdbms/drivers/mssql" "github.com/cortezaproject/corteza/server/store/adapters/rdbms/drivers/mysql" @@ -25,6 +27,7 @@ var ( func init() { helpers.RecursiveDotEnvLoad() + id.Init(cli.Context()) } func Test_RDBMS_SQLITE(t *testing.T) {