fix tests and lint #94
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
name: Build Anki deck | |
on: [push, pull_request] | |
jobs: | |
build-anki-deck: | |
name: Build Anki deck | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@master | |
- name: Set up Python 3.9 | |
uses: actions/setup-python@v1 | |
with: | |
python-version: 3.9 | |
- name: Install requirements | |
run: pip install -r requirements.txt | |
- name: Install sqlite | |
run: sudo apt-get install sqlite3 unzip | |
- name: Get current date | |
id: date | |
run: echo "::set-output name=date::$(date +'%Y-%m-%d_%H:%M:%S')" | |
- name: Get current timestamp | |
id: timestamp | |
run: echo "::set-output name=timestamp::$(date +'%s')" | |
- name: Test build Anki Deck | |
run: > | |
git clean -f -x -d | |
&& python generate.py --start 1 --stop 5 --page-size 2 | |
&& unzip leetcode.apkg | |
&& sqlite3 collection.anki2 .schema | |
&& sqlite3 collection.anki2 .dump | |
env: | |
LEETCODE_SESSION_ID: ${{ secrets.LEETCODE_SESSION_ID }} | |
LEETCODE_CSRF_TOKEN: ${{ secrets.LEETCODE_CSRF_TOKEN }} | |
- name: Test build Anki Deck (non-default output file) | |
run: > | |
git clean -f -x -d | |
&& python generate.py --stop 3 --output-file test.apkg | |
&& unzip test.apkg | |
&& sqlite3 collection.anki2 .schema | |
&& sqlite3 collection.anki2 .dump | |
env: | |
LEETCODE_SESSION_ID: ${{ secrets.LEETCODE_SESSION_ID }} | |
LEETCODE_CSRF_TOKEN: ${{ secrets.LEETCODE_CSRF_TOKEN }} | |
- name: Test build Anki Deck with Amazon list id | |
run: python generate.py --stop 10 --list-id 7p5x763 | |
env: | |
LEETCODE_SESSION_ID: ${{ secrets.LEETCODE_SESSION_ID }} | |
LEETCODE_CSRF_TOKEN: ${{ secrets.LEETCODE_CSRF_TOKEN }} | |
- name: Build Anki Deck | |
run: python generate.py | |
if: github.ref == 'refs/heads/master' | |
env: | |
LEETCODE_SESSION_ID: ${{ secrets.LEETCODE_SESSION_ID }} | |
LEETCODE_CSRF_TOKEN: ${{ secrets.LEETCODE_CSRF_TOKEN }} | |
- name: Create Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ github.ref }}-${{ steps.timestamp.outputs.timestamp }} | |
release_name: > | |
Anki Deck from ${{ github.ref }} on ${{ steps.date.outputs.date }} | |
draft: true | |
prerelease: true | |
- name: Upload release asset | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./leetcode.apkg | |
asset_name: leetcode.apkg | |
asset_content_type: application/octet-stream |