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

Move CI to GitHub Issues #940

Closed
simonw opened this issue Aug 16, 2020 · 20 comments
Closed

Move CI to GitHub Issues #940

simonw opened this issue Aug 16, 2020 · 20 comments
Labels

Comments

@simonw
Copy link
Owner

simonw commented Aug 16, 2020

It looks like the tests take 3m33s to run in GitHub Actions, but they're taking more than 8 minutes in Travis

@simonw simonw changed the title Move Move CI to GitHub Issues Aug 16, 2020
@simonw simonw added the ci label Aug 16, 2020
@simonw
Copy link
Owner Author

simonw commented Aug 16, 2020

I need to figure out how to build and push the Docker image on releases. Here's the Travis code for that:

datasette/.travis.yml

Lines 38 to 47 in 52eabb0

- 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

@simonw
Copy link
Owner Author

simonw commented Aug 16, 2020

I'd like to set these up as different workflows that depend on each other, if that's possible.

I want to start three test runs in parallel (on three different Python versions), then if all three pass kick off the PyPI push (without running more tests), then if that passes do the Docker build and push.

@simonw
Copy link
Owner Author

simonw commented Aug 16, 2020

https://docs.github.com/en/actions/getting-started-with-github-actions/core-concepts-for-github-actions#job

A set of steps that execute on the same runner. You can define the dependency rules for how jobs run in a workflow file. Jobs can run at the same time in parallel or run sequentially depending on the status of a previous job. For example, a workflow can have two sequential jobs that build and test code, where the test job is dependent on the status of the build job. If the build job fails, the test job will not run.

@simonw
Copy link
Owner Author

simonw commented Aug 16, 2020

When I figure this out I'll update the https://github.com/simonw/datasette-plugin/blob/main/datasette-%7B%7Bcookiecutter.hyphenated%7D%7D/.github/workflows/publish.yml default workflow to do this - right now it runs the tests once on just a single version of Python as part of the package deploy to PyPI step.

@simonw
Copy link
Owner Author

simonw commented Aug 16, 2020

This example of jobs depending on each other and sharing data via artifacts looks relevant: https://docs.github.com/en/actions/configuring-and-managing-workflows/persisting-workflow-data-using-artifacts#passing-data-between-jobs-in-a-workflow

@simonw
Copy link
Owner Author

simonw commented Aug 18, 2020

I think ${GITHUB_REF#refs/tags/} is the equivalent of $TRAVIS_TAG.

@simonw
Copy link
Owner Author

simonw commented Aug 18, 2020

I think this is ready. I'll only know for sure the first time I push a release through it though!

simonw added a commit that referenced this issue Aug 18, 2020
* Run CI on GitHub Actions, not Travis - refs #940
* Update documentation refs to Travis
* Release action now runs parallel tests, then pushes to PyPI, then Docker Hub
@simonw
Copy link
Owner Author

simonw commented Aug 18, 2020

I'll close this after the next release successfully goes out.

@simonw
Copy link
Owner Author

simonw commented Aug 18, 2020

I tested this new publish pattern (running the tests in parallel before the deploy step) on github-to-sqlite - skipping the Docker step - and it worked: https://github.com/dogsheep/github-to-sqlite/actions/runs/213809864

@simonw
Copy link
Owner Author

simonw commented Sep 14, 2020

Package deploys are still broken, just got this error trying to ship 0.49a1: https://github.com/simonw/datasette/actions/runs/253099665

The workflow is not valid. .github/workflows/publish.yml (Line: 61, Col: 9): Unexpected symbol: '"a"'. Located at position 24 within expression: !(contains(github.ref, "a") || contains(github.ref, "b"))

@simonw
Copy link
Owner Author

simonw commented Sep 14, 2020

This bit here:

deploy_docker:
runs-on: ubuntu-latest
needs: [deploy]
if: |
!(contains(github.ref, "a") || contains(github.ref, "b"))

@simonw
Copy link
Owner Author

simonw commented Sep 14, 2020

I think those should be single quoted.

simonw added a commit that referenced this issue Sep 14, 2020
@simonw
Copy link
Owner Author

simonw commented Sep 14, 2020

That worked: https://github.com/simonw/datasette/runs/1110040212?check_suite_focus=true ran and deployed https://pypi.org/project/datasette/0.49a1/ to PyPI but it skipped the push to Docker step because there was an "a" in the tag.

@simonw
Copy link
Owner Author

simonw commented Sep 14, 2020

Just release Datasette 0.49 - which shipped to PyPI just fine but skipped the Docker step for some reason!

https://github.com/simonw/datasette/runs/1114585275?check_suite_focus=true

Release_0_49_·_simonw_datasette_c024952

@simonw
Copy link
Owner Author

simonw commented Sep 14, 2020

I bet that's because the github.ref actually looks like this:

${GITHUB_REF#refs/tags/}

And the refs/tags/ part has an a in it.

@simonw
Copy link
Owner Author

simonw commented Sep 14, 2020

So now I've released Datasette 0.49 but failed to push a new Docker image. This is bad, and I need to fix it.

I'd like to push to Docker from GitHub Actions, so I think I'm going to create a one-off workflow task for doing that.

@simonw
Copy link
Owner Author

simonw commented Sep 14, 2020

Using https://github.com/marketplace/actions/debugging-with-tmate to manually submit a new build from within an interactive GitHub Actions session.

@simonw
Copy link
Owner Author

simonw commented Sep 14, 2020

I'm going to switch to using this logic to decide if I should ship to Docker: https://github.community/t/release-prerelease-action-triggers/17275/2

if: "!github.event.release.prerelease"

@simonw
Copy link
Owner Author

simonw commented Sep 14, 2020

I shipped the Docker build manually by running the following in a tmate session:

docker login
# Typed my username and password interactively
export REPO=datasetteproject/datasette 
docker build -f Dockerfile -t $REPO:0.49 . 
docker tag $REPO:0.49 $REPO:latest
docker push $REPO 

@simonw
Copy link
Owner Author

simonw commented Sep 14, 2020

I'm going to cross my fingers and hope that this works - I don't want to leave this issue open until Datasette 0.50.

@simonw simonw closed this as completed Sep 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant