Fix: Coba perbaikan cache pakay setup-python@4 #27
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
# This file is part of DataSae and is released under | |
# the AGPL-3.0-only License: https://opensource.org/license/agpl-v3/ | |
name: Python Application | |
on: [pull_request, push] | |
jobs: | |
lint: | |
name: Linter Test | |
runs-on: ubuntu-latest | |
container: | |
image: pipelinecomponents/flake8 | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Lint with flake8 | |
run: flake8 | |
unittest: | |
name: Unit Test | |
if: github.event_name == 'pull_request' || contains('refs/heads/main refs/heads/develop', github.ref) | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.7' | |
- name: Install dependencies | |
run: pip install . | |
- name: Test | |
run: python -m unittest | |
build: | |
name: Build Python Package | |
if: always() | |
needs: [lint, unittest] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.7' | |
cache: pip | |
- name: Install dependencies | |
run: pip install build twine | |
- name: Restore cache | |
id: cache-python-package | |
uses: actions/cache/restore@v3 | |
with: | |
path: dist/ | |
key: python-package | |
- name: Clear old cache | |
if: steps.cache-python-package.outputs.cache-hit == 'true' | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
run: gh cache delete python-package | |
- name: Build package | |
run: python -m build | |
- name: Save cache | |
uses: actions/cache/save@v3 | |
with: | |
path: dist/ | |
key: python-package | |
publish: | |
name: Publish Package to TestPyPI | |
if: always() | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.7' | |
cache: pip | |
- name: Cache package | |
uses: actions/cache@v3 | |
with: | |
path: dist/ | |
key: python-package | |
- name: Publish package | |
run: | | |
python -m twine \ | |
upload \ | |
--repository-url https://test.pypi.org/legacy/ \ | |
-u __token__ \ | |
-p ${{ secrets.TESTPYPI_TOKEN }} \ | |
--skip-existing \ | |
dist/* |