Skip to content

Commit

Permalink
Add github actions caching
Browse files Browse the repository at this point in the history
  • Loading branch information
baniasbaabe committed Nov 24, 2023
1 parent 97cf23a commit af2d9dc
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions book/codequality/cicd.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,60 @@
"source": [
"act"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Cache Python Dependencies in GitHub Actions"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Don’t waste time for your GitHub Actions workflows.\n",
"\n",
"Whenever a new run is triggered, your dependencies are probably installed again and again and again…\n",
"\n",
"Even if you didn’t change anything in your dependency file.\n",
"\n",
"With the small snippet below, the action caches your dependencies so you can skip the install step the next time your workflow runs."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"vscode": {
"languageId": "plaintext"
}
},
"outputs": [],
"source": [
"name: ci\n",
"\n",
"on:\n",
" push:\n",
" branches: [ main ]\n",
" \n",
"jobs:\n",
"\n",
" build:\n",
"\n",
" runs-on: ubuntu-latest\n",
" \n",
" steps:\n",
" - uses: actions/checkout@v4\n",
" - uses: actions/setup-python@v4\n",
" with:\n",
" python-version: '3.9'\n",
" cache: 'pip' # caching pip dependencies (supports poetry and pipenv too)\n",
" - run: pip install -r requirements.txt\n",
"\n",
" - name: Run Python unit tests\n",
" run: python3 -u -m unittest tests/tests.py"
]
}
],
"metadata": {
Expand Down

0 comments on commit af2d9dc

Please sign in to comment.