From 0fd7880bbabd4e28e53645324bdb8e903a16b6cd Mon Sep 17 00:00:00 2001 From: Simon Willison Date: Tue, 9 Jul 2024 15:01:11 -0700 Subject: [PATCH 1/3] Port CI to GitHub Actions and remove CircleCI --- .circleci/config.yml | 46 ------------------------------ .github/workflows/ci.yml | 61 ++++++++++++++++++++++++++++++++++++++++ README.md | 2 +- 3 files changed, 62 insertions(+), 47 deletions(-) delete mode 100644 .circleci/config.yml create mode 100644 .github/workflows/ci.yml diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index ee420446..00000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,46 +0,0 @@ -# https://circleci.com/docs/2.0/language-python/ -# -version: 2 -jobs: - build: - docker: - - image: cimg/python:3.11.2 - - image: circleci/postgres:12.6 - environment: - POSTGRES_USER: circleci - POSTGRES_DB: circle_test - POSTGRES_HOST_AUTH_METHOD: trust - - steps: - - checkout - - # Download and cache dependencies - - restore_cache: - keys: - - v1-dependencies-{{ checksum "requirements.txt" }} - # fallback to using the latest cache if no exact match is found - - v1-dependencies- - - - run: - name: install dependencies and setup database - command: | - export DATABASE_URL=postgres://circleci:@localhost/circle_test - pip install -U pip setuptools - pip install -r requirements.txt - python manage.py migrate --noinput - python manage.py collectstatic - - # run tests! - # this example uses Django's built-in test-runner - # other common Python testing frameworks include pytest and nose - # https://pytest.org - # https://nose.readthedocs.io - - run: - name: run tests - command: | - export DATABASE_URL=postgres://circleci:@localhost/circle_test - python manage.py test - - - store_artifacts: - path: test-reports - destination: test-reports diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..b6a461ee --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,61 @@ +name: CI + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + build: + runs-on: ubuntu-latest + + services: + postgres: + image: postgres:12.6 + env: + POSTGRES_USER: postgres + POSTGRES_DB: test_db + POSTGRES_HOST_AUTH_METHOD: trust + ports: + - 5432:5432 + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + + steps: + - name: Check out code + uses: actions/checkout@v2 + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: 3.11 + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + + - name: Set up database + run: | + sudo apt-get install -y postgresql-client + export DATABASE_URL=postgres://postgres:@localhost/test_db + python manage.py migrate --noinput + python manage.py collectstatic --noinput + + - name: Run tests + run: | + export DATABASE_URL=postgres://postgres:@localhost/test_db + python manage.py test + + - name: Store test reports + if: always() + uses: actions/upload-artifact@v2 + with: + name: test-reports + path: test-reports diff --git a/README.md b/README.md index 382743e0..14419b8e 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # simonwillisonblog -[![CircleCI](https://circleci.com/gh/simonw/simonwillisonblog.svg?style=svg)](https://circleci.com/gh/simonw/simonwillisonblog) [![Dependabot Status](https://api.dependabot.com/badges/status?host=github&repo=simonw/simonwillisonblog)](https://dependabot.com) +[![GitHub Actions](https://github.com/simonw/simonwillisonblog/actions/workflows/ci.yml/badge.svg)](https://github.com/simonw/simonwillisonblog/actions) The code that runs my weblog, http://simonwillison.net/ From d404be7b632150ae678cc09ec6d2b8eb05f2e4db Mon Sep 17 00:00:00 2001 From: Simon Willison Date: Tue, 9 Jul 2024 15:06:37 -0700 Subject: [PATCH 2/3] Clean up GitHub Actions config --- .github/workflows/ci.yml | 31 ++++++------------------------- 1 file changed, 6 insertions(+), 25 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b6a461ee..905a9ea2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,20 +1,13 @@ name: CI -on: - push: - branches: - - main - pull_request: - branches: - - main +on: [push, pull_request] jobs: build: runs-on: ubuntu-latest - services: postgres: - image: postgres:12.6 + image: postgres env: POSTGRES_USER: postgres POSTGRES_DB: test_db @@ -26,36 +19,24 @@ jobs: --health-interval 10s --health-timeout 5s --health-retries 5 - steps: - name: Check out code - uses: actions/checkout@v2 - + uses: actions/checkout@v4 - name: Set up Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v5 with: - python-version: 3.11 - + python-version: "3.12" + cache: pip - name: Install dependencies run: | - python -m pip install --upgrade pip pip install -r requirements.txt - - name: Set up database run: | sudo apt-get install -y postgresql-client export DATABASE_URL=postgres://postgres:@localhost/test_db python manage.py migrate --noinput python manage.py collectstatic --noinput - - name: Run tests run: | export DATABASE_URL=postgres://postgres:@localhost/test_db python manage.py test - - - name: Store test reports - if: always() - uses: actions/upload-artifact@v2 - with: - name: test-reports - path: test-reports From af719f80b45fd9f67b2d9a686edbed3f6048dbd5 Mon Sep 17 00:00:00 2001 From: Simon Willison Date: Tue, 9 Jul 2024 15:08:48 -0700 Subject: [PATCH 3/3] Test on Python 3.11 Got a pkg_resources error on 3.12 --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 905a9ea2..504835a9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,7 +25,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v5 with: - python-version: "3.12" + python-version: "3.11" cache: pip - name: Install dependencies run: |