Skip to content

Commit

Permalink
Merge pull request #2 from IPLSplatoon/1.2.0
Browse files Browse the repository at this point in the history
1.2.0 Update
  • Loading branch information
vlee489 authored Sep 14, 2024
2 parents 5135174 + be0aadb commit a22dc89
Show file tree
Hide file tree
Showing 15 changed files with 954 additions and 110 deletions.
25 changes: 24 additions & 1 deletion .github/workflows/publish-to-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,30 @@ jobs:
virtualenvs-in-project: true
installer-parallel: true
- name: Install dependencies
run: poetry install --no-interaction --no-root
run: poetry install --no-interaction --no-root --with=dev,ci
- name: Check Schema Hash with upstream
run: |
source .venv/bin/activate
python scripts/checkUpstreamSchema.py
- name: Run tests
env:
REPORT_OUTPUT: md_report.md
shell: bash
run: |
source .venv/bin/activate
echo "REPORT_FILE=${REPORT_OUTPUT}" >> "$GITHUB_ENV"
pytest -v --md-report --md-report-flavor gfm --md-report-exclude-outcomes passed skipped xpassed --md-report-output "$REPORT_OUTPUT"
- name: Output reports to the job summary when tests fail
if: failure()
shell: bash
run: |
if [ -f "$REPORT_FILE" ]; then
echo "<details><summary>Failed Test Report</summary>" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
cat "$REPORT_FILE" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "</details>" >> $GITHUB_STEP_SUMMARY
fi
- name: Mint token
id: mint
uses: tschm/token-mint-action@v1.0.2
Expand Down
52 changes: 52 additions & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Pull request

# Make sure only the latest push to the PR's source branch runs and cancel any on-going previous run
concurrency:
group: ${{ github.head_ref }}
cancel-in-progress: true

on:
pull_request:

jobs:
Pull-Request:
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Set up python
id: setup-python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true
- name: Install dependencies
run: poetry install --no-interaction --no-root --with=dev,ci
- name: Check Schema Hash with upstream
run: |
source .venv/bin/activate
python scripts/checkUpstreamSchema.py
- name: Install library
run: poetry install --no-interaction
- name: Run tests
env:
REPORT_OUTPUT: md_report.md
shell: bash
run: |
source .venv/bin/activate
echo "REPORT_FILE=${REPORT_OUTPUT}" >> "$GITHUB_ENV"
pytest -v --md-report --md-report-flavor gfm --md-report-exclude-outcomes passed skipped xpassed --md-report-output "$REPORT_OUTPUT"
- name: Render the report to the PR when tests fail
uses: marocchino/sticky-pull-request-comment@v2
if: failure()
with:
header: test-report
recreate: true
path: ${{ env.REPORT_FILE }}
45 changes: 45 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,48 @@ asyncio.run(run())
## Getting an API Key
To use this library, you must have an API key. You need to DM Sendou for an API Key currently.

## Development
For development, you'll need [Poetry](https://python-poetry.org) installed for dependency management and building distributions

### Dev Dependencies
When install dependencies for development run

```bash
poetry install --with=dev
```

*In CI you way want to run `poetry install --with=dev,ci` that includes CI dependencies for GitHub Actions*

### Testing
This package has *some* tests, these are written with pytest and can be run with

```bash
pytest
```

*You likely need to run `poetry install` before executing pytest*

### Tracking Upstream Schema
This package uses sendou.ink's [Public API Schema](https://github.com/Sendouc/sendou.ink/blob/rewrite/app/features/api-public/schema.ts)
file to design the models uses in the package. To keep track of where the package is in relation to the upstream schema,
the commit sha of the upstream schema is kept in the `pyproject.toml` file under `tool.sendou-py.source`.

There are 2 scripts that help keep this package inline with the upstream schema.

#### Upstream Schema Commit SHA checker
This script uses the GitHub API to check that the SHA stored in `tool.sendou-py.source` matches the latest commit for
for the upstream schema.

```bash
python3 python3 scripts/checkUpstreamSchema.py
```


#### Update local SHA with Upstream Schema Commit SHA
This script pulls down the latest SHA hash for the upstream schema and saves it to the `pyproject.toml` file

```bash
python3 scripts/updateUpstreamSchema.py
```

**This should only be run after dev has checked their changes match the upstream schema**
Loading

0 comments on commit a22dc89

Please sign in to comment.