From 11b553784c228bc369cd614076ede13dd4accdbc Mon Sep 17 00:00:00 2001 From: Sonny Bakker Date: Tue, 22 Oct 2024 21:44:57 +0200 Subject: [PATCH 1/9] Remove gitlab CI configuration --- .gitlab-ci.yml | 29 ----------------------------- gitlab-ci/build.yml | 7 ------- gitlab-ci/lint.yml | 25 ------------------------- gitlab-ci/release.yml | 12 ------------ gitlab-ci/test.yml | 20 -------------------- 5 files changed, 93 deletions(-) delete mode 100644 .gitlab-ci.yml delete mode 100644 gitlab-ci/build.yml delete mode 100644 gitlab-ci/lint.yml delete mode 100644 gitlab-ci/release.yml delete mode 100644 gitlab-ci/test.yml 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 From 1f3594d5dbb7b0a058912f87e17b52845f5aaa1b Mon Sep 17 00:00:00 2001 From: Sonny Bakker Date: Tue, 22 Oct 2024 21:45:04 +0200 Subject: [PATCH 2/9] Add test workflow --- .forgejo/workflows/demo.yml | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .forgejo/workflows/demo.yml diff --git a/.forgejo/workflows/demo.yml b/.forgejo/workflows/demo.yml new file mode 100644 index 0000000..d470cda --- /dev/null +++ b/.forgejo/workflows/demo.yml @@ -0,0 +1,6 @@ +on: [push] +jobs: + test: + runs-on: docker + steps: + - run: echo All Good From b34737ef208237afa4f1b54048d13e65c5a042f4 Mon Sep 17 00:00:00 2001 From: Sonny Bakker Date: Tue, 22 Oct 2024 22:31:20 +0200 Subject: [PATCH 3/9] Add tests workflow --- .forgejo/workflows/demo.yml | 6 --- .forgejo/workflows/tests.yml | 57 ++++++++++++++++++++++++ src/newsreader/conf/{gitlab.py => ci.py} | 2 +- 3 files changed, 58 insertions(+), 7 deletions(-) delete mode 100644 .forgejo/workflows/demo.yml create mode 100644 .forgejo/workflows/tests.yml rename src/newsreader/conf/{gitlab.py => ci.py} (97%) diff --git a/.forgejo/workflows/demo.yml b/.forgejo/workflows/demo.yml deleted file mode 100644 index d470cda..0000000 --- a/.forgejo/workflows/demo.yml +++ /dev/null @@ -1,6 +0,0 @@ -on: [push] -jobs: - test: - runs-on: docker - steps: - - run: echo All Good diff --git a/.forgejo/workflows/tests.yml b/.forgejo/workflows/tests.yml new file mode 100644 index 0000000..cea1f66 --- /dev/null +++ b/.forgejo/workflows/tests.yml @@ -0,0 +1,57 @@ +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: + - 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/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 From f9a4aff0b46e5d9052ada0f0d8a485fe17d84316 Mon Sep 17 00:00:00 2001 From: Sonny Bakker Date: Wed, 23 Oct 2024 08:24:56 +0200 Subject: [PATCH 4/9] Use python image for tests --- .forgejo/workflows/tests.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.forgejo/workflows/tests.yml b/.forgejo/workflows/tests.yml index cea1f66..7fa3e6b 100644 --- a/.forgejo/workflows/tests.yml +++ b/.forgejo/workflows/tests.yml @@ -9,6 +9,7 @@ env: jobs: test: runs-on: docker + container: 'python:3.11' services: postgres: @@ -24,9 +25,6 @@ jobs: steps: - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 - with: - python-version: '3.11' - uses: actions/cache@v4 with: path: "${{ GITHUB_WORKSPACE }}/.cache/uv" From 9972f38651fa414137fb4ba8ed961479dfb4224d Mon Sep 17 00:00:00 2001 From: Sonny Bakker Date: Wed, 23 Oct 2024 08:31:31 +0200 Subject: [PATCH 5/9] Revert "Use python image for tests" This reverts commit f9a4aff0b46e5d9052ada0f0d8a485fe17d84316. --- .forgejo/workflows/tests.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.forgejo/workflows/tests.yml b/.forgejo/workflows/tests.yml index 7fa3e6b..cea1f66 100644 --- a/.forgejo/workflows/tests.yml +++ b/.forgejo/workflows/tests.yml @@ -9,7 +9,6 @@ env: jobs: test: runs-on: docker - container: 'python:3.11' services: postgres: @@ -25,6 +24,9 @@ jobs: steps: - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: '3.11' - uses: actions/cache@v4 with: path: "${{ GITHUB_WORKSPACE }}/.cache/uv" From 34d48dea39e513d457cefe1745d5f968f1b5210e Mon Sep 17 00:00:00 2001 From: Sonny Bakker Date: Wed, 23 Oct 2024 09:07:58 +0200 Subject: [PATCH 6/9] Use ubuntu-latest --- .forgejo/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.forgejo/workflows/tests.yml b/.forgejo/workflows/tests.yml index cea1f66..17dab1b 100644 --- a/.forgejo/workflows/tests.yml +++ b/.forgejo/workflows/tests.yml @@ -8,7 +8,7 @@ env: jobs: test: - runs-on: docker + runs-on: ubuntu-latest services: postgres: From 8c70a32c7b749eb50fb4638730fea2cab24918ae Mon Sep 17 00:00:00 2001 From: Sonny Bakker Date: Wed, 23 Oct 2024 09:09:13 +0200 Subject: [PATCH 7/9] Revert "Use ubuntu-latest" This reverts commit 34d48dea39e513d457cefe1745d5f968f1b5210e. --- .forgejo/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.forgejo/workflows/tests.yml b/.forgejo/workflows/tests.yml index 17dab1b..cea1f66 100644 --- a/.forgejo/workflows/tests.yml +++ b/.forgejo/workflows/tests.yml @@ -8,7 +8,7 @@ env: jobs: test: - runs-on: ubuntu-latest + runs-on: docker services: postgres: From 649d52755ed9bce0378935df28eb76c7a45b0661 Mon Sep 17 00:00:00 2001 From: Sonny Bakker Date: Wed, 23 Oct 2024 09:31:51 +0200 Subject: [PATCH 8/9] Use setup-node --- .forgejo/workflows/tests.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.forgejo/workflows/tests.yml b/.forgejo/workflows/tests.yml index cea1f66..e9d0b10 100644 --- a/.forgejo/workflows/tests.yml +++ b/.forgejo/workflows/tests.yml @@ -23,6 +23,9 @@ jobs: image: memcached:1.5.22 steps: + - uses: actions/setup-node@v4 + with: + node-version: 'lts/*' - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: From cefc2ca8a7edbe165ad14a55b862916b8d355841 Mon Sep 17 00:00:00 2001 From: Sonny Bakker Date: Wed, 23 Oct 2024 09:43:10 +0200 Subject: [PATCH 9/9] Install platform node before setting up lts version --- .forgejo/workflows/tests.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.forgejo/workflows/tests.yml b/.forgejo/workflows/tests.yml index e9d0b10..800b452 100644 --- a/.forgejo/workflows/tests.yml +++ b/.forgejo/workflows/tests.yml @@ -23,6 +23,8 @@ jobs: 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/*'