Skip to content

Commit d93af6c

Browse files
authored
Merge pull request #14 from firefly-cpp/improve-workflow-use-poetry
Improve workflows
2 parents 37cc040 + 761a927 commit d93af6c

File tree

2 files changed

+53
-36
lines changed

2 files changed

+53
-36
lines changed

.github/workflows/python-app.yml

Lines changed: 0 additions & 36 deletions
This file was deleted.

.github/workflows/test.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: fireflyalgorithm
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
build:
11+
12+
runs-on: ${{ matrix.os }}
13+
strategy:
14+
matrix:
15+
os: [ubuntu-latest, windows-latest, macos-latest]
16+
python-version: ['3.9', '3.10']
17+
defaults:
18+
run:
19+
shell: bash
20+
21+
steps:
22+
- uses: actions/checkout@v3
23+
- name: Set up Python ${{ matrix.python-version }}
24+
uses: actions/setup-python@v3
25+
with:
26+
python-version: ${{ matrix.python-version }}
27+
- name: Get full Python version
28+
id: full-python-version
29+
run: echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))")
30+
- name: Install poetry
31+
run: |
32+
curl -sL https://install.python-poetry.org | python - -y
33+
- name: Update path
34+
if: ${{ matrix.os != 'windows-latest' }}
35+
run: echo "$HOME/.local/bin" >> $GITHUB_PATH
36+
- name: Update Windows path
37+
if: ${{ matrix.os == 'windows-latest' }}
38+
run: echo "$APPDATA\Python\Scripts" >> $GITHUB_PATH
39+
- name: Configure poetry
40+
run: poetry config virtualenvs.in-project true
41+
- name: Set up cache
42+
uses: actions/cache@v3
43+
id: cache
44+
with:
45+
path: .venv
46+
key: venv-${{ runner.os }}-${{ steps.full-python-version.outputs.version }}-${{ hashFiles('**/poetry.lock') }}
47+
- name: Ensure cache is healthy
48+
if: steps.cache.outputs.cache-hit == 'true'
49+
run: timeout 10s poetry run pip --version || rm -rf .venv
50+
- name: Install dependencies
51+
run: poetry install
52+
- name: Run tests
53+
run: poetry run pytest

0 commit comments

Comments
 (0)