From 1ad445a9c0629fea4affb01c63de001a3580eb48 Mon Sep 17 00:00:00 2001 From: Simon Willison Date: Sun, 16 Aug 2020 12:12:43 -0700 Subject: [PATCH 1/3] Run CI on GitHub Actions, not Travis - refs #940 --- .github/workflows/publish.yml | 37 +++++++++++++++++++++++++++ .github/workflows/test.yml | 29 +++++++++++++++++++++ .travis.yml | 47 ----------------------------------- 3 files changed, 66 insertions(+), 47 deletions(-) create mode 100644 .github/workflows/publish.yml create mode 100644 .github/workflows/test.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000000..5b707703e8 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,37 @@ +name: Publish Python Package + +on: + release: + types: [created] + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: '3.8' + - uses: actions/cache@v2 + name: Configure pip caching + with: + path: ~/.cache/pip + key: ${{ runner.os }}-publish-pip-${{ hashFiles('**/setup.py') }} + restore-keys: | + ${{ runner.os }}-publish-pip- + - name: Install dependencies + run: | + pip install -e '.[test]' + pip install setuptools wheel twine + - name: Run tests + run: pytest + - name: Publish + if: success() + env: + TWINE_USERNAME: __token__ + TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} + run: | + python setup.py sdist bdist_wheel + twine upload dist/* + diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000000..74e56e13bf --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,29 @@ +name: Test + +on: [push] + +jobs: + test: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: [3.6, 3.7, 3.8] + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - uses: actions/cache@v2 + name: Configure pip caching + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ hashFiles('**/setup.py') }} + restore-keys: | + ${{ runner.os }}-pip- + - name: Install dependencies + run: | + pip install -e '.[test]' + - name: Run tests + run: | + pytest diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 181bc3f3af..0000000000 --- a/.travis.yml +++ /dev/null @@ -1,47 +0,0 @@ -language: python -dist: xenial - -branches: - except: - - master - -# 3.6 is listed first so it gets used for the later build stages -python: - - "3.6" - - "3.7" - - "3.8" - -# Executed for 3.5 AND 3.5 as the first "test" stage: -script: - - pip install -U pip wheel - - pip install .[test] - - pytest - -cache: - directories: - - $HOME/.cache/pip - -# This defines further stages that execute after the tests -jobs: - include: - - stage: release tagged version - if: tag IS present - python: 3.6 - deploy: - - provider: pypi - user: simonw - distributions: "sdist bdist_wheel" - password: ${PYPI_PASSWORD} - on: - branch: master - tags: true - - stage: publish docker image - if: (tag IS present) AND NOT (tag =~ [ab]) - python: 3.6 - script: - # Build and release to Docker Hub - - docker login -u $DOCKER_USER -p $DOCKER_PASS - - export REPO=datasetteproject/datasette - - docker build -f Dockerfile -t $REPO:$TRAVIS_TAG . - - docker tag $REPO:$TRAVIS_TAG $REPO:latest - - docker push $REPO From 6de1eb208958f269e14e3e042ad5bbc6b30938e4 Mon Sep 17 00:00:00 2001 From: Simon Willison Date: Sun, 16 Aug 2020 12:18:43 -0700 Subject: [PATCH 2/3] Update documentation refs to Travis --- .dockerignore | 1 - README.md | 2 +- docs/contributing.rst | 2 +- docs/index.rst | 4 ++-- setup.py | 2 +- 5 files changed, 5 insertions(+), 6 deletions(-) diff --git a/.dockerignore b/.dockerignore index 938173e97b..490f509ea4 100644 --- a/.dockerignore +++ b/.dockerignore @@ -3,7 +3,6 @@ .eggs .gitignore .ipynb_checkpoints -.travis.yml build *.spec *.egg-info diff --git a/README.md b/README.md index ee3246a5f1..38ea7f79e4 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ [![PyPI](https://img.shields.io/pypi/v/datasette.svg)](https://pypi.org/project/datasette/) [![Changelog](https://img.shields.io/github/v/release/simonw/datasette?label=changelog)](https://docs.datasette.io/en/stable/changelog.html) [![Python 3.x](https://img.shields.io/pypi/pyversions/datasette.svg?logo=python&logoColor=white)](https://pypi.org/project/datasette/) -[![Travis CI](https://travis-ci.org/simonw/datasette.svg?branch=main)](https://travis-ci.org/simonw/datasette) +[![Tests](https://github.com/simonw/datasette/workflows/Test/badge.svg)](https://github.com/simonw/datasette/actions?query=workflow%3ATest) [![Documentation Status](https://readthedocs.org/projects/datasette/badge/?version=latest)](https://docs.datasette.io/en/latest/?badge=latest) [![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://github.com/simonw/datasette/blob/main/LICENSE) [![docker: datasette](https://img.shields.io/badge/docker-datasette-blue)](https://hub.docker.com/r/datasetteproject/datasette) diff --git a/docs/contributing.rst b/docs/contributing.rst index 118146cf6c..95663dbcfa 100644 --- a/docs/contributing.rst +++ b/docs/contributing.rst @@ -126,7 +126,7 @@ Now browse to ``http://localhost:8000/`` to view the documentation. Any edits yo Release process --------------- -Datasette releases are performed using tags. When a new version tag is pushed to GitHub, a `Travis CI task `__ will perform the following: +Datasette releases are performed using tags. When a new release is published on GitHub, a `GitHub Action workflow `__ will perform the following: * Run the unit tests against all supported Python versions. If the tests pass... * Build a Docker image of the release and push a tag to https://hub.docker.com/r/datasetteproject/datasette diff --git a/docs/index.rst b/docs/index.rst index f9f2f0bbc8..946fa54216 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -10,8 +10,8 @@ datasette| :target: https://docs.datasette.io/en/stable/changelog.html .. |Python 3.x| image:: https://img.shields.io/pypi/pyversions/datasette.svg?logo=python&logoColor=white :target: https://pypi.org/project/datasette/ -.. |Travis CI| image:: https://travis-ci.org/simonw/datasette.svg?branch=main - :target: https://travis-ci.org/simonw/datasette +.. |Tests| image:: https://github.com/simonw/datasette/workflows/Test/badge.svg + :target: https://github.com/simonw/datasette/actions?query=workflow%3ATest .. |License| image:: https://img.shields.io/badge/license-Apache%202.0-blue.svg :target: https://github.com/simonw/datasette/blob/main/LICENSE .. |docker: datasette| image:: https://img.shields.io/badge/docker-datasette-blue diff --git a/setup.py b/setup.py index bbd0aa8bbe..d952614917 100644 --- a/setup.py +++ b/setup.py @@ -38,7 +38,7 @@ def get_version(): "Live demo": "https://latest.datasette.io/", "Source code": "https://github.com/simonw/datasette", "Issues": "https://github.com/simonw/datasette/issues", - "CI": "https://travis-ci.org/simonw/datasette", + "CI": "https://github.com/simonw/datasette/actions?query=workflow%3ATest", }, packages=find_packages(exclude=("tests",)), package_data={"datasette": ["templates/*.html"]}, From f5a72e11b632b01acc41c07f6f4cfffa1a7ed14e Mon Sep 17 00:00:00 2001 From: Simon Willison Date: Mon, 17 Aug 2020 22:04:25 -0700 Subject: [PATCH 3/3] Parallel tests, then push to PyPI, then Docker Hub Refs #940 --- .github/workflows/publish.yml | 45 +++++++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 5 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 5b707703e8..4e554eda31 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -5,8 +5,33 @@ on: types: [created] jobs: + test: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: [3.6, 3.7, 3.8] + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - uses: actions/cache@v2 + name: Configure pip caching + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ hashFiles('**/setup.py') }} + restore-keys: | + ${{ runner.os }}-pip- + - name: Install dependencies + run: | + pip install -e '.[test]' + - name: Run tests + run: | + pytest deploy: runs-on: ubuntu-latest + needs: [test] steps: - uses: actions/checkout@v2 - name: Set up Python @@ -22,16 +47,26 @@ jobs: ${{ runner.os }}-publish-pip- - name: Install dependencies run: | - pip install -e '.[test]' pip install setuptools wheel twine - - name: Run tests - run: pytest - name: Publish - if: success() env: TWINE_USERNAME: __token__ TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} run: | python setup.py sdist bdist_wheel twine upload dist/* - + deploy_docker: + runs-on: ubuntu-latest + needs: [deploy] + steps: + - uses: actions/checkout@v2 + - name: Build and push to Docker Hub + env: + DOCKER_USER: ${{ secrets.DOCKER_USER }} + DOCKER_PASS: ${{ secrets.DOCKER_PASS }} + run: |- + docker login -u $DOCKER_USER -p $DOCKER_PASS + export REPO=datasetteproject/datasette + docker build -f Dockerfile -t $REPO::${GITHUB_REF#refs/tags/} . + docker tag $REPO::${GITHUB_REF#refs/tags/} $REPO:latest + docker push $REPO