Skip to content

Instantly share code, notes, and snippets.

@kjaymiller
Last active March 28, 2023 19:00
Show Gist options
  • Save kjaymiller/59e6763300c8f4226e47f51f3177f743 to your computer and use it in GitHub Desktop.
Save kjaymiller/59e6763300c8f4226e47f51f3177f743 to your computer and use it in GitHub Desktop.
Snippet for PyTest GH Actions

This is the snippet and action that will get you quickly setup with pytest for your GitHub Actions.

The snippet can be added to VS Code Snippets for rapid adding to a new project.

name: Test
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v4
with:
python-version: 3.11
cache: 'pip'
- name: Test
run: |
pip install -r requirements.txt
python -m pytest
// Snippet for PyTest GH Action
"PyTest GH Actions": {
"prefix": "pytest GH Action",
"body": [
"name: Test",
"on: [push, pull_request]",
"jobs:",
"\ttest:",
"\t\truns-on: ubuntu-latest",
"\t\tsteps:",
"\t\t- uses: actions/checkout@v2",
"\t\t- uses: actions/setup-python@v4",
"\t\t with:",
"\t\t\t\tpython-version: 3.11",
"\t\t\t\tcache: 'pip'",
"\t\t- name: Test",
"\t\t run: |",
"\t\t\t\tpip install -r requirements.txt",
"\t\t\t\tpython -m pytest"
],
"description": "Creates the GH Action for Running PyTest"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment