diff --git a/.forgejo/workflows/tests.yml b/.forgejo/workflows/tests.yml new file mode 100644 index 0000000..800b452 --- /dev/null +++ b/.forgejo/workflows/tests.yml @@ -0,0 +1,62 @@ +on: [ push ] + +env: + POSTGRES_HOST: "postgres" + POSTGRES_DB: "newsreader" + POSTGRES_USER: "newsreader" + POSTGRES_PASSWORD: "newsreader" + +jobs: + test: + runs-on: docker + + services: + postgres: + image: postgres:15 + env: + POSTGRES_HOST: "${{ env.POSTGRES_HOST }}" + POSTGRES_DB: "${{ env.POSTGRES_NAME }}" + POSTGRES_NAME: "${{ env.POSTGRES_NAME }}" + POSTGRES_USER: "${{ env.POSTGRES_USER }}" + POSTGRES_PASSWORD: "${{ env.POSTGRES_PASSWORD }}" + memcached: + image: memcached:1.5.22 + + steps: + - run: apt-get --yes update && apt-get --yes install nodejs git + + - uses: actions/setup-node@v4 + with: + node-version: 'lts/*' + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: '3.11' + - uses: actions/cache@v4 + with: + path: "${{ GITHUB_WORKSPACE }}/.cache/uv" + key: ${{ runner.os }}-uv-${{ hashFiles('uv.lock') }} + restore-keys: | + ${{ runner.os }}-uv- + - uses: actions/cache@v4 + with: + path: "${{ GITHUB_WORKSPACE }}/.cache/pip" + key: ${{ runner.os }}-pip- + restore-keys: | + ${{ runner.os }}-pip- + + - run: pip install uv + env: + PIP_CACHE_DIR: "${{ GITHUB_WORKSPACE }}/.cache/pip" + - run: uv sync --extra testing --extra ci + env: + UV_CHACHE_DIR: "${{ GITHUB_WORKSPACE }}/.cache/uv" + + - run: ./.venv/bin/coverage run ./src/manage.py test newsreader + env: + DJANGO_SETTINGS_MODULE: "newsreader.conf.ci" + POSTGRES_HOST: "${{ env.POSTGRES_HOST }}" + POSTGRES_DB: "${{ env.POSTGRES_NAME }}" + POSTGRES_NAME: "${{ env.POSTGRES_NAME }}" + POSTGRES_USER: "${{ env.POSTGRES_USER }}" + POSTGRES_PASSWORD: "${{ env.POSTGRES_PASSWORD }}" diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml deleted file mode 100644 index bf64808..0000000 --- a/.gitlab-ci.yml +++ /dev/null @@ -1,29 +0,0 @@ -stages: - - build - - test - - lint - - release - -variables: - UV_CACHE_DIR: "$CI_PROJECT_DIR/.cache/uv" - PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip" - DJANGO_SETTINGS_MODULE: "newsreader.conf.gitlab" - POSTGRES_HOST: "$POSTGRES_HOST" - POSTGRES_DB: "$POSTGRES_NAME" - POSTGRES_NAME: "$POSTGRES_NAME" - POSTGRES_USER: "$POSTGRES_USER" - POSTGRES_PASSWORD: "$POSTGRES_PASSWORD" - -cache: - key: "$CI_COMMIT_REF_SLUG" - paths: - - .cache/pip - - .cache/uv - - node_modules/ - - .venv/ - -include: - - local: '/gitlab-ci/build.yml' - - local: '/gitlab-ci/test.yml' - - local: '/gitlab-ci/lint.yml' - - local: '/gitlab-ci/release.yml' diff --git a/gitlab-ci/build.yml b/gitlab-ci/build.yml deleted file mode 100644 index 5a86f07..0000000 --- a/gitlab-ci/build.yml +++ /dev/null @@ -1,7 +0,0 @@ -static: - stage: build - image: node:lts - before_script: - - npm install - script: - - npm run build diff --git a/gitlab-ci/lint.yml b/gitlab-ci/lint.yml deleted file mode 100644 index 6511f9a..0000000 --- a/gitlab-ci/lint.yml +++ /dev/null @@ -1,25 +0,0 @@ -python-linting: - stage: lint - image: python:3.11 - before_script: - - pip install uv - - uv sync --extra testing --extra ci - script: - - ./.venv/bin/ruff check src/ - - ./.venv/bin/ruff format --check src/ - only: - refs: - - main - - merge_requests - -javascript-linting: - stage: lint - image: node:lts - before_script: - - npm install - script: - - npm run lint - only: - refs: - - main - - merge_requests diff --git a/gitlab-ci/release.yml b/gitlab-ci/release.yml deleted file mode 100644 index 571be3c..0000000 --- a/gitlab-ci/release.yml +++ /dev/null @@ -1,12 +0,0 @@ -release: - stage: release - image: registry.gitlab.com/gitlab-org/release-cli:latest - rules: - - if: $CI_COMMIT_TAG - script: - - echo 'running release job' - release: - name: 'Release $CI_COMMIT_TAG' - description: './CHANGELOG.md' - tag_name: '$CI_COMMIT_TAG' - ref: '$CI_COMMIT_TAG' diff --git a/gitlab-ci/test.yml b/gitlab-ci/test.yml deleted file mode 100644 index 69bc93f..0000000 --- a/gitlab-ci/test.yml +++ /dev/null @@ -1,20 +0,0 @@ -python-tests: - stage: test - coverage: '/TOTAL\s+\d+\s+\d+\s+(\d+%)/' - services: - - postgres:15 - - memcached:1.5.22 - image: python:3.11 - before_script: - - pip install uv - - uv sync --extra testing --extra ci - script: - - ./.venv/bin/coverage run ./src/manage.py test newsreader - -javascript-tests: - stage: test - image: node:lts - before_script: - - npm install - script: - - npm test diff --git a/src/newsreader/conf/gitlab.py b/src/newsreader/conf/ci.py similarity index 97% rename from src/newsreader/conf/gitlab.py rename to src/newsreader/conf/ci.py index e08556d..40c4a2f 100644 --- a/src/newsreader/conf/gitlab.py +++ b/src/newsreader/conf/ci.py @@ -33,7 +33,7 @@ CACHES = { # Project settings VERSION = get_current_version() -ENVIRONMENT = "gitlab" +ENVIRONMENT = "ci" try: # Optionally use sentry integration