mirror of
https://github.com/go-vikunja/vikunja.git
synced 2026-02-01 22:47:40 +00:00
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: kolaente <k@knt.li>
368 lines
12 KiB
YAML
368 lines
12 KiB
YAML
name: Test
|
|
|
|
on:
|
|
workflow_call:
|
|
|
|
jobs:
|
|
mage:
|
|
runs-on: ubuntu-latest
|
|
name: prepare-mage
|
|
steps:
|
|
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
|
|
- name: Set up Go
|
|
uses: actions/setup-go@0aaccfd150d50ccaeb58ebd88d36e91967a5f35b # v5
|
|
with:
|
|
go-version: stable
|
|
- name: Cache Mage
|
|
id: cache-mage
|
|
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4
|
|
with:
|
|
key: ${{ runner.os }}-build-mage-${{ hashFiles('magefile.go') }}
|
|
path: |
|
|
./mage-static
|
|
- name: Compile Mage
|
|
if: ${{ steps.cache-mage.outputs.cache-hit != 'true' }}
|
|
uses: magefile/mage-action@6f50bbb8ea47d56e62dee92392788acbc8192d0b # v3
|
|
with:
|
|
version: latest
|
|
args: -compile ./mage-static
|
|
- name: Store Mage Binary
|
|
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
|
|
with:
|
|
name: mage_bin
|
|
path: ./mage-static
|
|
|
|
api-build:
|
|
runs-on: ubuntu-latest
|
|
needs: mage
|
|
steps:
|
|
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
|
|
- name: Download Mage Binary
|
|
uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e # v4
|
|
with:
|
|
name: mage_bin
|
|
- name: Git describe
|
|
id: ghd
|
|
uses: proudust/gh-describe@v2
|
|
- name: Set up Go
|
|
uses: actions/setup-go@0aaccfd150d50ccaeb58ebd88d36e91967a5f35b # v5
|
|
with:
|
|
go-version: stable
|
|
- name: Build
|
|
env:
|
|
RELEASE_VERSION: ${{ steps.ghd.outputs.describe }}
|
|
run: |
|
|
mkdir -p frontend/dist
|
|
touch frontend/dist/index.html
|
|
chmod +x ./mage-static
|
|
./mage-static build
|
|
- name: Store Vikunja Binary
|
|
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
|
|
with:
|
|
name: vikunja_bin
|
|
path: ./vikunja
|
|
|
|
api-lint:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
|
|
- uses: actions/setup-go@0aaccfd150d50ccaeb58ebd88d36e91967a5f35b # v5
|
|
with:
|
|
go-version: stable
|
|
- name: prepare frontend files
|
|
run: |
|
|
mkdir -p frontend/dist
|
|
touch frontend/dist/index.html
|
|
- name: golangci-lint
|
|
uses: golangci/golangci-lint-action@1481404843c368bc19ca9406f87d6e0fc97bdcfd # v7
|
|
with:
|
|
version: v2.0.0
|
|
|
|
api-check-translations:
|
|
runs-on: ubuntu-latest
|
|
needs: mage
|
|
steps:
|
|
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
|
|
- name: Download Mage Binary
|
|
uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e # v4
|
|
with:
|
|
name: mage_bin
|
|
- name: Check
|
|
run: |
|
|
chmod +x ./mage-static
|
|
./mage-static check:translations
|
|
|
|
test-migration-smoke:
|
|
runs-on: ubuntu-latest
|
|
needs:
|
|
- api-build
|
|
strategy:
|
|
matrix:
|
|
db:
|
|
- sqlite
|
|
- postgres
|
|
- mysql
|
|
services:
|
|
migration-smoke-db-mysql:
|
|
image: mariadb:11@sha256:310d29fbb58169dcddb384b0ff138edb081e2773d6e2eceb976b3668089f2f84
|
|
env:
|
|
MYSQL_ROOT_PASSWORD: vikunjatest
|
|
MYSQL_DATABASE: vikunjatest
|
|
ports:
|
|
- 3306:3306
|
|
migration-smoke-db-postgres:
|
|
image: postgres:16@sha256:e95b0cb95f719e0ce156c2bc5545c89fbd98a1a692845a5331ddc79ea61f1b1e
|
|
env:
|
|
POSTGRES_PASSWORD: vikunjatest
|
|
POSTGRES_DB: vikunjatest
|
|
ports:
|
|
- 5432:5432
|
|
steps:
|
|
- name: Download Unstable
|
|
run: |
|
|
wget https://dl.vikunja.io/api/unstable/vikunja-unstable-linux-amd64-full.zip -q -O vikunja-latest.zip
|
|
unzip vikunja-latest.zip vikunja-unstable-linux-amd64
|
|
- name: Download Vikunja Binary
|
|
uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e # v4
|
|
with:
|
|
name: vikunja_bin
|
|
- name: run migration
|
|
env:
|
|
VIKUNJA_DATABASE_TYPE: ${{ matrix.db }}
|
|
VIKUNJA_DATABASE_PATH: ./vikunja-migration-test.db
|
|
VIKUNJA_DATABASE_USER: ${{ matrix.db == 'postgres' && 'postgres' || 'root' }}
|
|
VIKUNJA_DATABASE_PASSWORD: vikunjatest
|
|
VIKUNJA_DATABASE_DATABASE: vikunjatest
|
|
VIKUNJA_DATABASE_SSLMODE: disable
|
|
VIKUNJA_LOG_DATABASE: stdout
|
|
VIKUNJA_LOG_DATABASELEVEL: debug
|
|
run: |
|
|
# Wait for MySQL to be ready if using MySQL
|
|
if [ "$VIKUNJA_DATABASE_TYPE" = "mysql" ]; then
|
|
echo "Waiting for MySQL to be ready..."
|
|
until mysql -h 127.0.0.1 -u root -pvikunjatest -e "SELECT 1" &> /dev/null; do
|
|
echo "MySQL not ready yet, waiting 2 seconds..."
|
|
sleep 2
|
|
done
|
|
echo "MySQL is ready!"
|
|
fi
|
|
|
|
# Wait for PostgreSQL to be ready if using PostgreSQL
|
|
if [ "$VIKUNJA_DATABASE_TYPE" = "postgres" ]; then
|
|
echo "Waiting for PostgreSQL to be ready..."
|
|
until PGPASSWORD=vikunjatest psql -h 127.0.0.1 -U postgres -d vikunjatest -c "SELECT 1" &> /dev/null; do
|
|
echo "PostgreSQL not ready yet, waiting 2 seconds..."
|
|
sleep 2
|
|
done
|
|
echo "PostgreSQL is ready!"
|
|
fi
|
|
|
|
./vikunja-unstable-linux-amd64 migrate
|
|
# Run the migrations from the binary built in the step before
|
|
chmod +x vikunja
|
|
./vikunja migrate
|
|
|
|
test-api:
|
|
runs-on: ubuntu-latest
|
|
needs:
|
|
- mage
|
|
strategy:
|
|
matrix:
|
|
db:
|
|
- sqlite-in-memory
|
|
- sqlite
|
|
- postgres
|
|
- mysql
|
|
test:
|
|
- unit
|
|
- integration
|
|
services:
|
|
db-mysql:
|
|
image: mariadb:11@sha256:310d29fbb58169dcddb384b0ff138edb081e2773d6e2eceb976b3668089f2f84
|
|
env:
|
|
MYSQL_ROOT_PASSWORD: vikunjatest
|
|
MYSQL_DATABASE: vikunjatest
|
|
ports:
|
|
- 3306:3306
|
|
db-postgres:
|
|
image: postgres:16@sha256:e95b0cb95f719e0ce156c2bc5545c89fbd98a1a692845a5331ddc79ea61f1b1e
|
|
env:
|
|
POSTGRES_PASSWORD: vikunjatest
|
|
POSTGRES_DB: vikunjatest
|
|
ports:
|
|
- 5432:5432
|
|
test-ldap:
|
|
image: gitea/test-openldap@sha256:b66527e298d6062d5289dc411d1b8da1c593f8140a3d1f863e8d9d021234122f
|
|
ports:
|
|
- 389:389
|
|
steps:
|
|
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
|
|
- name: Download Mage Binary
|
|
uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e # v4
|
|
with:
|
|
name: mage_bin
|
|
- name: test
|
|
env:
|
|
VIKUNJA_TESTS_USE_CONFIG: ${{ matrix.db != 'sqlite-in-memory' && 1 || 0 }}
|
|
VIKUNJA_DATABASE_TYPE: ${{ matrix.db }}
|
|
VIKUNJA_DATABASE_USER: ${{ matrix.db == 'postgres' && 'postgres' || 'root' }}
|
|
VIKUNJA_DATABASE_PASSWORD: vikunjatest
|
|
VIKUNJA_DATABASE_DATABASE: vikunjatest
|
|
VIKUNJA_DATABASE_SSLMODE: disable
|
|
VIKUNJA_AUTH_LDAP_ENABLED: 1
|
|
VIKUNJA_AUTH_LDAP_HOST: localhost
|
|
VIKUNJA_AUTH_LDAP_USETLS: 0
|
|
VIKUNJA_AUTH_LDAP_BASEDN: dc=planetexpress,dc=com
|
|
VIKUNJA_AUTH_LDAP_BINDDN: uid=gitea,ou=service,dc=planetexpress,dc=com
|
|
VIKUNJA_AUTH_LDAP_BINDPASSWORD: password
|
|
VIKUNJA_AUTH_LDAP_USERFILTER: '(&(objectclass=inetorgperson)(uid=%s))'
|
|
run: |
|
|
mkdir -p frontend/dist
|
|
touch frontend/dist/index.html
|
|
chmod +x mage-static
|
|
./mage-static test:${{ matrix.test }}
|
|
|
|
frontend-dependencies:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
|
|
- uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4
|
|
name: Install pnpm
|
|
with:
|
|
run_install: false
|
|
package_json_file: frontend/package.json
|
|
- name: Install Node.js
|
|
uses: actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e # v4
|
|
with:
|
|
node-version: 22
|
|
cache: 'pnpm'
|
|
cache-dependency-path: frontend/pnpm-lock.yaml
|
|
- name: Install dependencies
|
|
run: |
|
|
cd frontend
|
|
pnpm install
|
|
|
|
frontend-lint:
|
|
runs-on: ubuntu-latest
|
|
needs:
|
|
- frontend-dependencies
|
|
steps:
|
|
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
|
|
- uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4
|
|
name: Install pnpm
|
|
with:
|
|
run_install: false
|
|
package_json_file: frontend/package.json
|
|
- name: Install Node.js
|
|
uses: actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e # v4
|
|
with:
|
|
node-version: 22
|
|
cache: 'pnpm'
|
|
cache-dependency-path: frontend/pnpm-lock.yaml
|
|
- name: Lint
|
|
run: |
|
|
cd frontend
|
|
pnpm install
|
|
pnpm lint
|
|
|
|
frontend-typecheck:
|
|
runs-on: ubuntu-latest
|
|
needs:
|
|
- frontend-dependencies
|
|
steps:
|
|
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
|
|
- uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4
|
|
name: Install pnpm
|
|
with:
|
|
run_install: false
|
|
package_json_file: frontend/package.json
|
|
- name: Install Node.js
|
|
uses: actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e # v4
|
|
with:
|
|
node-version: 22
|
|
cache: 'pnpm'
|
|
cache-dependency-path: frontend/pnpm-lock.yaml
|
|
- name: Typecheck
|
|
continue-on-error: true
|
|
run: |
|
|
cd frontend
|
|
pnpm install
|
|
pnpm typecheck
|
|
|
|
test-frontend-unit:
|
|
runs-on: ubuntu-latest
|
|
needs:
|
|
- frontend-dependencies
|
|
steps:
|
|
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
|
|
- uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4
|
|
name: Install pnpm
|
|
with:
|
|
run_install: false
|
|
package_json_file: frontend/package.json
|
|
- name: Install Node.js
|
|
uses: actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e # v4
|
|
with:
|
|
node-version: 22
|
|
cache: 'pnpm'
|
|
cache-dependency-path: frontend/pnpm-lock.yaml
|
|
- name: Run unit tests
|
|
run: |
|
|
cd frontend
|
|
pnpm install
|
|
pnpm test:unit
|
|
|
|
test-frontend-e2e:
|
|
runs-on: ubuntu-latest
|
|
needs:
|
|
- frontend-dependencies
|
|
- api-build
|
|
steps:
|
|
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
|
|
- uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4
|
|
name: Install pnpm
|
|
with:
|
|
run_install: false
|
|
package_json_file: frontend/package.json
|
|
- name: Install Node.js
|
|
uses: actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e # v4
|
|
with:
|
|
node-version: 22
|
|
cache: 'pnpm'
|
|
cache-dependency-path: frontend/pnpm-lock.yaml
|
|
- name: Download Vikunja Binary
|
|
uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e # v4
|
|
with:
|
|
name: vikunja_bin
|
|
- name: Build frontend for test
|
|
run: |
|
|
cd frontend
|
|
pnpm install
|
|
pnpm cypress install
|
|
pnpm build:test
|
|
- name: Run api
|
|
env:
|
|
VIKUNJA_SERVICE_TESTINGTOKEN: averyLongSecretToSe33dtheDB
|
|
VIKUNJA_LOG_LEVEL: DEBUG
|
|
VIKUNJA_CORS_ENABLE: 1
|
|
VIKUNJA_DATABASE_PATH: memory
|
|
VIKUNJA_DATABASE_TYPE: sqlite
|
|
run: |
|
|
chmod +x ./vikunja
|
|
./vikunja &
|
|
- uses: cypress-io/github-action@v6
|
|
with:
|
|
working-directory: frontend
|
|
browser: chrome
|
|
record: true
|
|
start: |
|
|
pnpm preview:test
|
|
wait-on: http://127.0.0.1:4173,http://127.0.0.1:3456/api/v1/info
|
|
wait-on-timeout: 10
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
|
|
CYPRESS_API_URL: http://127.0.0.1:3456/api/v1
|
|
CYPRESS_TEST_SECRET: averyLongSecretToSe33dtheDB
|
|
CYPRESS_DEFAULT_COMMAND_TIMEOUT: 60000
|