From 698504468a95885cf43b4fafec53f714d07c313d Mon Sep 17 00:00:00 2001 From: Harpo Date: Fri, 3 Nov 2023 16:08:59 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=AC=20Workflow=20Actions=20(#76)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Adds actions from Chowda * Splits wagtail-tests * Uses docker volume, upgrades to postgres16 * Adds documentation on image tag usage * Renames ci.yml to CI.yml * Renames test db in Actions --- .github/workflows/CD.yml | 19 +++++++++++++++ .github/workflows/CI.yml | 21 ++++++++++++++++ .github/workflows/ci.yml | 17 ------------- .github/workflows/publish.yml | 46 +++++++++++++++++++++++++++++++++++ .github/workflows/release.yml | 11 +++++++++ .github/workflows/update.yml | 12 +++++++++ dev.yml | 1 - docker-compose.yml | 24 ++++++------------ ov | 16 ++++++------ test.yml | 14 +++++++++++ 10 files changed, 139 insertions(+), 42 deletions(-) create mode 100644 .github/workflows/CD.yml create mode 100644 .github/workflows/CI.yml delete mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/publish.yml create mode 100644 .github/workflows/release.yml create mode 100644 .github/workflows/update.yml create mode 100644 test.yml diff --git a/.github/workflows/CD.yml b/.github/workflows/CD.yml new file mode 100644 index 0000000..98e69dd --- /dev/null +++ b/.github/workflows/CD.yml @@ -0,0 +1,19 @@ +name: ๐Ÿช‚ Deploy + +on: + push: + branches: + - main + pull_request: + branches: + - main + release: + types: [published, edited, prereleased] + workflow_dispatch: + +jobs: + build: + name: ๐Ÿ”จ Build and deploy docker image + uses: WGBH-MLA/.github/.github/workflows/build.yml@main + with: + target: production diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml new file mode 100644 index 0000000..c7f8fa7 --- /dev/null +++ b/.github/workflows/CI.yml @@ -0,0 +1,21 @@ +name: ๐Ÿงช Integration Tests + +on: [push, pull_request, workflow_dispatch] + +jobs: + tests: + name: โš—๏ธ Application Tests + uses: WGBH-MLA/.github/.github/workflows/pytest-with-postgres.yml@main + secrets: inherit + with: + pdm_args: -G test,ci + pytest_args: -n auto --nbmake -ra -s + pg_db: ov-test + + lint: + name: ๐Ÿ‘• Lint + uses: WGBH-MLA/.github/.github/workflows/lint.yml@main + + black: + name: ๐Ÿ–ค Black + uses: WGBH-MLA/.github/.github/workflows/black.yml@main diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index b646ae4..0000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,17 +0,0 @@ -name: ๐Ÿงช CI Tests - -on: - push: - branches: - - master - pull_request: - -jobs: - build: - runs-on: ubuntu-latest - steps: - - name: ๐Ÿ“ฐ Checkout - uses: actions/checkout@v3 - - - name: โ˜‘๏ธ Run Tests - run: ./ov test diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..56876a5 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,46 @@ +name: ๐Ÿ› Publish to PyPi +on: + workflow_dispatch: + push: + tags: + - '*' + +jobs: + build: + name: ๐Ÿ“ฆ Build package + runs-on: ubuntu-latest + steps: + - name: ๐Ÿ“ฐ Checkout + uses: actions/checkout@v3 + + - name: ๐Ÿ“ฒ Setup PDM + uses: pdm-project/setup-pdm@v3 + id: setup-python + with: + python-version: 3.x + + - name: ๐Ÿšš Install dependencies + run: pdm install --prod + + - name: ๐Ÿ—๏ธ Build package + run: pdm build + + - name: ๐Ÿ›ซ Export build files + uses: actions/upload-artifact@v3 + with: + name: dist + path: dist + + publish: + name: ๐Ÿ—ž Publish package + needs: build + runs-on: ubuntu-latest + environment: pypi + permissions: + id-token: write + steps: + - name: ๐Ÿ›ฌ Download artifacts + uses: actions/download-artifact@v3 + + - name: ๐Ÿ—ž Publish package + uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..c2596db --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,11 @@ +name: ๐Ÿ“ฆ Release + +on: + milestone: + types: [closed] + workflow_dispatch: + +jobs: + release: + name: ๐Ÿ“ Draft Release + uses: WGBH-MLA/.github/.github/workflows/draft_release.yml@main diff --git a/.github/workflows/update.yml b/.github/workflows/update.yml new file mode 100644 index 0000000..51895df --- /dev/null +++ b/.github/workflows/update.yml @@ -0,0 +1,12 @@ +name: ๐Ÿ› Update dependencies +# On Wednesdays, we update our dependencies. + +on: + schedule: + - cron: 0 12 * * 3 + workflow_dispatch: + +jobs: + update: + name: ๐Ÿฆฟ Update dependencies + uses: WGBH-MLA/.github/.github/workflows/update.yml@main diff --git a/dev.yml b/dev.yml index bd7e68a..0adc672 100644 --- a/dev.yml +++ b/dev.yml @@ -8,7 +8,6 @@ services: - db environment: OV_DB_HOST: db - # OV_DB_PASSWORD: env_file: - .env db: diff --git a/docker-compose.yml b/docker-compose.yml index 02b9d67..b58fcdc 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,7 +5,8 @@ services: build: context: . target: base - image: ov-wag + # Use the `image` property to run a prebuilt image from GHCR instead of building locally. Requires disabling the `build` section above. + # image: ghcr.io/wgbh-mla/ov-wag:main volumes: - ./:/app/ entrypoint: /app/docker_entrypoints/dev.sh @@ -15,20 +16,11 @@ services: delay: 5s max_attempts: 3 window: 5s - wagtail-tests: - build: - context: . - target: test - image: ov-tests - volumes: - - ./:/app/ - entrypoint: /app/docker_entrypoints/test.sh - environment: - - OV_DB_ENGINE=django.db.backends.sqlite3 - - OV_DB_NAME=testdb db: - image: postgres:14.2-alpine - volumes: - - ./db:/var/lib/postgresql/data:Z - user: ${UID}:${GID} + image: postgres:16-alpine restart: always + volumes: + - db:/var/lib/postgresql/data + +volumes: + db: diff --git a/ov b/ov index 0a38b96..48ded48 100755 --- a/ov +++ b/ov @@ -7,14 +7,14 @@ USAGE:\n\n COMMANDS:\n\n -\t b | build \t build the docker image\n -\t c | cmd \t run a bash command with the wagtail docker image\n -\t coverage \t run the coverage tests -\t d | dev \t start a development server\n -\t h | help \t prints this help text\n -\t s | shell \t enter into a python shell with the app context\n -\t t | test \t run the wagtail test suite -\t m | manage \t run a manage.py command +\t b | build \t build the docker image\n +\t c | cmd \t run a bash command with the wagtail docker image\n +\t cov | coverage\t run the coverage tests\n +\t d | dev \t start a development server\n +\t h | help \t prints this help text\n +\t s | shell \t enter into a python shell with the app context\n +\t t | test \t run the wagtail test suite\n +\t m | manage \t run a manage.py command\n\n " COMPOSE="docker compose -f docker-compose.yml" diff --git a/test.yml b/test.yml new file mode 100644 index 0000000..d47ba1d --- /dev/null +++ b/test.yml @@ -0,0 +1,14 @@ +version: '3.8' + +services: + tests: + build: + context: . + target: test + image: ov-tests + volumes: + - ./:/app/ + entrypoint: /app/docker_entrypoints/test.sh + environment: + - OV_DB_ENGINE=django.db.backends.sqlite3 + - OV_DB_NAME=testdb