Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update CI and migrate to Github Actions #58

Merged
merged 15 commits into from
Oct 16, 2023
81 changes: 0 additions & 81 deletions .circleci/config.yml

This file was deleted.

8 changes: 0 additions & 8 deletions .circleci/trigger-nightly-build.sh

This file was deleted.

30 changes: 30 additions & 0 deletions .github/report_nightly_build_failure.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
"""
Called by GitHub Action when the nightly build fails.

This reports an error to the #nightly-build-failures Slack channel.
"""
import os

import requests


if "SLACK_WEBHOOK_URL" in os.environ:
# https://docs.github.com/en/free-pro-team@latest/actions/reference/environment-variables#default-environment-variables
repository = os.environ["GITHUB_REPOSITORY"]
run_id = os.environ["GITHUB_RUN_ID"]
url = f"https://github.com/{repository}/actions/runs/{run_id}"

print("Reporting to #nightly-build-failures slack channel")
response = requests.post(
os.environ["SLACK_WEBHOOK_URL"],
json={
"text": f"A Nightly build failed. See {url}",
},
)

print(f"Slack responded with: {response}")

else:
print(
"Unable to report to #nightly-build-failures slack channel because SLACK_WEBHOOK_URL is not set"
)
54 changes: 54 additions & 0 deletions .github/workflows/nightly-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Nightly Wagtail test
# Inspired by: https://github.com/torchbox/wagtailmedia/blob/main/.github/workflows/nightly-tests.yml

on:
schedule:
# Run every Monday at midnight
- cron: "0 0 * * 1"

workflow_dispatch:

jobs:
nightly-test:
# Cannot check the existence of secrets, so limiting to repository name to prevent all forks to run nightly.
# See: https://github.com/actions/runner/issues/520
if: ${{ github.repository == 'wagtail-nest/wagtail-ab-testing' }}
runs-on: ubuntu-latest

services:
postgres:
image: postgres:16
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Install dependencies
run: |
python -m pip install tox requests
- name: Test
id: test
continue-on-error: true
env:
DATABASE_URL: postgres://postgres:postgres@localhost/wagtail_ab_testing
run: |
tox -e wagtailmain-postgres,wagtailmain-sqlite

- name: Send Slack notification on failure
if: steps.test.outcome == 'failure'
run: |
python .github/report_nightly_build_failure.py
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
104 changes: 104 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
name: Test & Lint
# Inspired by https://github.com/wagtail/wagtail-bakery/blob/0bfff2a7446e6119156279d22cfac2137960145d/.github/workflows/test.yml

on:
push:
branches:
- main
pull_request:
workflow_call: # Allow for the publish workflows to run the tests by calling this workflow

jobs:
qa_javascript:
name: JavaScript
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v3
with:
cache: 'npm'
node-version: 14
- name: Install dependencies
run: |
npm ci
- name: Lint JavaScript
run: |
npm run lint
- name: Compile JavaScript
run: |
npm run build

qa_python:
services:
postgres:
image: postgres:16
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
name: Python ${{ matrix.python}} ${{ matrix.toxenv }}
runs-on: ubuntu-latest
continue-on-error: ${{ matrix.experimental }}
strategy:
matrix:
python: ["3.8", "3.9", "3.10", "3.11"]
experimental: [false]
toxenv: ["py"]
include:
# Linting
- python: "3.11"
toxenv: flake8
experimental: false
# Future Wagtail release from main branch (allowed to fail)
- python: "3.11"
toxenv: wagtailmain-sqlite
experimental: true
- python: "3.11"
toxenv: wagtailmain-postgres
experimental: true
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}
- name: Install dependencies
run: |
python -m pip install tox coverage

# This step runs only for jobs NOT in the include matrix
- name: Run tox targets for Python ${{ matrix.python }}
if: ${{ matrix.toxenv == 'py' }}
run: |
# Run only the tox environments that match the Python version
tox run -f py$(echo ${{ matrix.python }} | tr -d .)
coverage combine
coverage report
# Codecov does not support the .coverage file generated by coverage, so we convert it to xml
coverage xml
env:
DATABASE_URL: postgres://postgres:postgres@localhost/wagtail_ab_testing
- name: Upload coverage reports to Codecov
if: ${{ matrix.toxenv == 'py' }}
uses: codecov/codecov-action@v3
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

# This step runs only for jobs in the include matrix and covers linting
- name: Run tox targets for Python ${{ matrix.python }} (${{ matrix.toxenv }})
if: ${{ matrix.toxenv != 'py' }}
run: |
tox -e ${{ matrix.toxenv }}
env:
TOXENV: ${{ matrix.toxenv }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/build
/dist
/wagtail_ab_testing.egg-info
/.coverage
/.coverage*
/htmlcov
/.tox
/venv
Expand Down
44 changes: 0 additions & 44 deletions .travis.yml

This file was deleted.

7 changes: 2 additions & 5 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@



BSD License

Copyright (c) 2020, Karl Hobley
Copyright (c) 2020-2023, Karl Hobley
2023, Wagtail Nest
All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
Expand All @@ -30,4 +28,3 @@ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
OF THE POSSIBILITY OF SUCH DAMAGE.

6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

[![Version](https://img.shields.io/pypi/v/wagtail-ab-testing.svg?style=flat)](https://pypi.python.org/pypi/wagtail-ab-testing/)
[![License](https://img.shields.io/badge/license-BSD-blue.svg?style=flat)](https://opensource.org/licenses/BSD-3-Clause)
[![codecov](https://img.shields.io/codecov/c/github/torchbox/wagtail-ab-testing?style=flat)](https://codecov.io/gh/torchbox/wagtail-ab-testing)
[![Language grade: Python](https://img.shields.io/lgtm/grade/python/g/torchbox/wagtail-ab-testing.svg?logo=lgtm&logoWidth=18&style=flat)](https://lgtm.com/projects/g/torchbox/wagtail-ab-testing/context:python)
[![Test & Lint](https://github.com/wagtail-nest/wagtail-ab-testing/actions/workflows/test.yml/badge.svg)](https://github.com/wagtail-nest/wagtail-ab-testing/actions/workflows/test.yml)
[![codecov](https://img.shields.io/codecov/c/github/wagtail-nest/wagtail-ab-testing?style=flat)](https://codecov.io/gh/wagtail-nest/wagtail-ab-testing)

Wagtail A/B Testing is an A/B testing package for Wagtail that allows users to create and manage A/B tests on pages through the Wagtail admin.

Expand All @@ -18,7 +18,7 @@ Key features:

## Usage

Wagtail A/B Testing works with Django 3.2+, Wagtail 4.1+ on Python 3.7+ environments.
Wagtail A/B Testing works with Django 3.2+, Wagtail 4.1+ on Python 3.8+ environments.

### Creating an A/B test

Expand Down
Loading