-
Notifications
You must be signed in to change notification settings - Fork 0
52 lines (44 loc) · 1.76 KB
/
main.yml
File metadata and controls
52 lines (44 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
name: Protfolio.Backend.API CI/CD
on:
# Trigger the workflow on push
push:
branches:
# Push events on main branch
- main
# The Job defines a series of steps that execute on the same runner.
jobs:
CI:
# Define the runner used in the workflow
runs-on: ubuntu-latest
steps:
# Check out repo so our workflow can access it
- uses: actions/checkout@v4
# Step-1 Setup Python
- name: Set up Python
# This action sets up a Python environment for use in actions
uses: actions/setup-python@v5
with:
python-version: '3.10'
# optional: architecture: x64 x64 or x86. Defaults to x64 if not specified
# Step-2 Install Python Virtual ENV
- name: Install Python Virtual ENV
run: pip3 install virtualenv
# Step-3 Setup Virtual ENV
# https://docs.github.com/en/actions/guides/caching-dependencies-to-speed-up-workflows
- name: Virtual ENV
uses: actions/cache@v4
id: cache-venv # name for referring later
with:
path: venv # what we cache: the Virtual ENV
# The cache key depends on requirements.txt
key: ${{ runner.os }}-venv-${{ hashFiles('**/requirements*.txt') }}
restore-keys: |
${{ runner.os }}-venv-
# Step-4 Build a Virtual ENV, but only if it doesn't already exist
- name: Activate Virtual ENV
run: python3 -m venv venv && source venv/bin/activate && pip3 install -r requirements.txt
if: steps.cache-venv.outputs.cache-hit != 'true'
# - name: Run Tests
# # Note that you have to activate the virtualenv in every step
# # because GitHub actions doesn't preserve the environment
# run: . venv/bin/activate && pytest