Guards! Guards! (Discworld, #8; City Watch, #1)
![]() |
Review:Probably my favourite in the series so far. |
![]() |
Review:Probably my favourite in the series so far. |
![]() |
|
This post has only one objective. The next person who wants to run the tests on his Python project hosted on GitHub should be able to read it and get his tests running in 15 minutes or less using GitHub Actions.
So, concepts:
This assumes your project is "modern" in that it uses Poetry for dependency management and packaging. Of course maybe it doesn't, but don't worry, that only is important for maybe 3 lines of YAML.
So, Github Actions runs what's called "workflows". You define these in YAML files
in .github/workflows/whatever.yml
in your repo.
Here's the original version of the workflow we'll be studying today: test.yml
Don't worry about the project it's in, it really doesn't matter.
Now, let's examine that file bit by bit with explanations, so you can see if something needs changing for you.
name: CI
on:
[push, pull_request]
This workflow is called "CI" and it runs on every push to any branch.
jobs:
build:
strategy:
matrix:
python-version: ["3.10"]
runs-on: ubuntu-latest
Put all the versions of Python you want to test in python-versions
. This will run the tests in Ubuntu.
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Switch to Current Branch
run: git checkout ${{ env.BRANCH }}
Checkout this repo we are testing, go to the right branch.
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
Install whatever Python version we are testing.
- name: Install dependencies
run: |
pip install poetry
poetry install
Install whatever you need. Since this project uses poetry, I install poetry and then use poetry to setup things. If you are using something else, then change it accordingly.
- name: Run unit tests
run: |
poetry run pytest
Run the tests in whatever way they need to run. Again, since I am using poetry, this works. If you are not, then change this as needed.
So, put this file in .github/workflows/test.yml
, modify as needed. Commit. Push.
Now your tests run on every push.
And that's it. If your project uses poetry, then this workflow may work unchanged (except maybe for Python versions?)
Good luck!
Vi algo en twitter, eso me hizo googlear, llegué a https://obsproject.com/forum/threads/180-degree-live-fisheye-distortion-correction.100214/ y ... terminé haciendo este video, que explica como hacer dos cosas, una útil, la otra ... no tanto (aunque es medio parecido a algo que apple mostró en WWDC!)
Sospecho que la única manera de que haga videos es que sean cosas así, espontáneas, sin mucho laburo atrás porque estoy haciendo muchas cosas y no tengo tiempo.
![]() |
Review:Why did I read this after I didn't quite like #2? I don't know. |