Skip to content

Commit

Permalink
fix: only try to publish from eyeonus repos
Browse files Browse the repository at this point in the history
fixes eyeonus#134

This makes the publish job dependent on being the eyeonus repository. It also moves the requirements files
into the top-level directory and organizes them into requirements, requirements-dev, and requirements-publish
which incrementally reference the previous requirements file to simplify them.

It's unusual for requirements*.txt to be in a subdirectory these days, and various tools are lazy about it,
which can make these chained-references problematic as some tools will intepret them relatively and some
won't; ergo having them in the tld together is less likely to suddenly not work one day.
  • Loading branch information
kfsone committed Apr 29, 2024
1 parent ba58077 commit b4a8238
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 33 deletions.
52 changes: 39 additions & 13 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,24 @@ jobs:
os:
- Ubuntu
- Windows
- MacOS
py:
- "3.12"
- "3.11"
- "3.10"
- "3.9"
- "3.8"
- "3.7"
exclude:
# It's unlikely people will be using 3.7 or 3.8 at this point on Win or Mac
- os: Windows
py: "3.7"
- os: Windows
py: "3.8"
- os: MacOS
py: "3.7"
- os: MacOS
py: "3.8"

steps:
- uses: actions/checkout@v4
Expand All @@ -31,25 +43,39 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.py }}

- name: Cache python packages
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('requirements*.txt') }}
restore-keys: ${{ runner.os }}-pip-

- name: Cache tox results
uses: actions/cache@v3
with:
path: .tox
key: ${{ runner.os }}-${{ matrix.py }}-tox-${{ hashFiles('tox.ini') }}-${{ hashFiles('requirements*.txt') }}
restore-keys: ${{ runner.os }}-${{ matrix.py }}-tox-

- name: Install dependencies
run: |
python3 -m pip install --upgrade pip
python3 -m pip install flake8 pytest
python3 -m pip install -r requirements/publish.txt
python3 -m pip install tox tox-gh-actions
# - name: Lint with flake8
# run: |
# # stop the build if there are Python syntax errors or undefined names
# flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
# flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
python3 -m pip install -q --upgrade pip
python3 -m pip install -q -r requirements-dev.txt
- name: Test with tox
# This will run flake8 tests (which will fail quickly) alongside running
# pylint for a deeper inspect and running unit tests for all available
# python interpreters in parallel
env:
TOX_PARALLEL_NO_SPINNER: 1
run: |
tox
tox --parallel
pypi-publish:
name: Upload release to PyPI
# Don't try to publish except when this is a push onto the main branch of the master repos.
if: github.repository == 'eyeonus/Trade-Dangerous' && github.event_name == 'push' && github.ref == 'refs/heads/release/v1'
needs: test
runs-on: ubuntu-latest
environment:
Expand All @@ -71,8 +97,8 @@ jobs:

- name: Install dependencies
run: |
python3 -m pip install --upgrade pip
python3 -m pip install -r requirements/publish.txt
python3 -m pip install -q --upgrade pip
python3 -m pip install -q -r requirements-publish.txt
- name: Configure git
run: |
Expand Down
15 changes: 7 additions & 8 deletions docs/develop.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Develop Trade-Dangerous
============================
=======================

## Setup Environment

Expand All @@ -9,19 +9,17 @@ git clone https://github.com/eyeonus/Trade-Dangerous
cd Trade-Dangerous
python3 -m venv venv
. venv/bin/activate
pip3 install -e .
pip3 install -r requirements/dev.txt
pip3 install -r requirements-dev.txt -e .
```

__Windows__
__Windows__ (powershell)
```powershell
git clone https://github.com/eyeonus/Trade-Dangerous
cd Trade-Dangerous
# This requires a python version >= 3.4.2
python3 -m venv venv
.\venv\Scripts\activate
pip3 install -e .
pip3 install -r requirements/dev.txt
.\venv\Scripts\activate.ps1
pip3 install -r requirements-dev.txt -e .
```

## Generate Documentation
Expand All @@ -39,7 +37,8 @@ cd docs
```

### Generate apidoc

```bash
cd docs
sphinx-apidoc -f -s md -o source/ ../tradedangerous ../tradedangerous/mfd ../tradedangerous/templates ../tradedangerous/commands
```
```
16 changes: 8 additions & 8 deletions requirements/dev.txt → requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
mistune<2.0.0
m2r
pytest
Sphinx
-r requirements.txt

tox
flake8
importlib-metadata>=1
wheel
pytest
tox-gh-actions
coverage
ijson
rich==13.7.1

Sphinx
mistune<2.0.0
m2r
3 changes: 2 additions & 1 deletion requirements/publish.txt → requirements-publish.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
-r dev.txt
-r requirements-dev.txt

packaging>=20.0
python-semantic-release
build
twine
wheel
5 changes: 5 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
appJar
requests
ijson
rich==13.7.1
importlib-metadata>=1
6 changes: 3 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ skipsdist = true # avoid installation
skip_missing_interpreters = true

[testenv]
deps = -r requirements/dev.txt
deps = -r requirements-dev.txt
passenv =
SYSTEMDRIVE, PROGRAMFILES
platform =
linux|linux2|darwin|nt|win32|win64
# changedir = {toxinidir}/tradedangerous # ?

[testenv:py{37,38,39,310,311}]
deps = -r requirements/dev.txt
deps = -r requirements-dev.txt
commands =
coverage run --source=tradedangerous -m pytest {posargs}
coverage report --show-missing
Expand Down Expand Up @@ -127,7 +127,7 @@ ignore =
[testenv:pylint]
deps =
pylint
-r requirements/dev.txt
-r requirements-dev.txt
commands =
pylint --rcfile {toxinidir}/tox.ini \
tradedangerous/__init__.py \
Expand Down

0 comments on commit b4a8238

Please sign in to comment.