diff --git a/.github/actions/setup-poetry-depencies/action.yml b/.github/actions/setup-poetry-dependencies/action.yml similarity index 100% rename from .github/actions/setup-poetry-depencies/action.yml rename to .github/actions/setup-poetry-dependencies/action.yml diff --git a/.github/actions/setup-poetry/action.yml b/.github/actions/setup-poetry/action.yml index b3c8c93..47597b5 100644 --- a/.github/actions/setup-poetry/action.yml +++ b/.github/actions/setup-poetry/action.yml @@ -48,3 +48,15 @@ runs: - name: Install Poetry for Windows if: runner.os == 'Windows' && steps.cached-poetry.outputs.cache-hit != 'true' + shell: pwsh + env: + POETRY_VERSION: ${{ inputs.poetry-version }} + POETRY_HOME: ${{ inputs.poetry-home }} + run: | + (Invoke-WebRequest -Uri https://install.python-poetry.org -UseBasicParsing).Content | py - + + - name: Add Poetry to the PATH environment variable + if: inputs.poetry-path != '' + shell: bash + run: | + echo "${{ inputs.poetry-path }}" >> $GITHUB_PATH diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..6d6720a --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,31 @@ +name: '🧪 Test' + +on: + workflow_dispatch: + push: + pull_request: + +jobs: + py-test: + uses: ./.github/workflows/tox-pytest.yml + with: + enable-test: true + +# determine-changes: +# if: | +# github.event_name != 'pull_request' || +# github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name +# runs-on: ubuntu-latest +# outputs: +# has-changes: ${{ fromJson(steps.filter.outputs.changes)[0] != null }} +# py: ${{ steps.filter.outputs.py }} +# py-test: ${{ steps.filter.outputs.py-test }} +# steps: +# - name: Checkout +# uses: actions/checkout@v3 + +# - name: Categorize changed files +# uses: dorny/paths-filter@v2 +# id: filter +# with: +# filters: .github/settings/test-filters.yml diff --git a/.github/workflows/tox-pytest.yml b/.github/workflows/tox-pytest.yml index e3ca39e..9167822 100644 --- a/.github/workflows/tox-pytest.yml +++ b/.github/workflows/tox-pytest.yml @@ -25,26 +25,28 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-latest, macos-latest, windows-latest] - python-version: ['3.7', '3.8', '3.9', '3.10'] - poetry_version: ['1.3.1'] + # os: [ubuntu-latest, macos-latest, windows-latest] + os: [ubuntu-latest, macos-latest] + # python-version: ['3.9'] + python-version: ['3.8', '3.9', '3.10'] + poetry-version: ['1.8.3'] include: - os: ubuntu-latest - poetry_home: '' - poetry_path: '' - poetry_cache_paths: | + poetry-home: '' + poetry-path: '' + poetry-cache-paths: | ~/.local/share/pypoetry ~/.local/bin/poetry - os: macos-latest - poetry_home: '' - poetry_path: ${HOME}/.local/bin - poetry_cache_paths: | + poetry-home: '' + poetry-path: ${HOME}/.local/bin + poetry-cache-paths: | ~/Library/Application Support/pypoetry ~/.local/bin/poetry - os: windows-latest - poetry_home: '' - poetry_path: ${APPDATA}\pypoetry\venv\Scripts - poetry_cache_paths: | + poetry-home: '' + poetry-path: ${APPDATA}\pypoetry\venv\Scripts + poetry-cache-paths: | ~\AppData\Roaming\pypoetry ~\AppData\Roaming\Python\Scripts\poetry.exe poetry-cache-key-fmt: ['poetry-{0}-{1}-python-{2}'] @@ -86,18 +88,14 @@ jobs: with: cache-key: ${{ format(matrix.venv-cache-key-fmt, matrix.os, steps.setup-python.outputs.python-version, hashFiles('**/poetry.lock')) }} python-version: ${{ steps.setup-python.outputs.python-version }} - poetry-install-args: --no-interaction --no-root --with dev + poetry-install-args: --no-interaction --with dev - name: Test with pytest id: test-with-pytest if: inputs.enable-test == true run: | ${{ steps.setup-poetry-dependencies.outputs.venv-activate }} - tox -v - # tox -e py -- -v --color=yes - # deactivate - # # Create a dummy file. - # touch "dummy-$(echo .coverage.*)" + tox -e py -- -v - name: Upload coverage reports if: steps.test-with-pytest.conclusion != 'skipped' && matrix.enable-coverage == 'true' @@ -107,24 +105,28 @@ jobs: path: .coverage.* retention-days: 1 - - name: Get Total Coverage from coverage.json - if: steps.test-with-pytest.conclusion != 'skipped' && matrix.enable-coverage == 'true' + - name: "Export Coverage Percentage" + id: report-coverage + if: inputs.enable-test == true run: | - export TOTAL=$(python -c "import json;print(json.load(open('coverage.json'))['totals']['percent_covered_display'])") - echo "### Total coverage: ${TOTAL}%" >> $GITHUB_STEP_SUMMARY + ${{ steps.setup-poetry-dependencies.outputs.venv-activate }} + tox -e report + export TOTAL=$(python -c "import json;print(json.load(open('coverage.json'))['totals']['percent_covered_display'])") + echo "total=$TOTAL" >> $GITHUB_ENV + echo "### Total coverage: ${TOTAL}%" >> $GITHUB_STEP_SUMMARY - - name: "Make badge" - uses: schneegans/dynamic-badges-action@v1.4.0 - with: - # GIST_TOKEN is a GitHub personal access token with scope "gist". - auth: ${{ secrets.GIST_TOKEN }} - gistID: 5f5c84f28e80b29f2f9ce92300859446 # replace with your real Gist id. - filename: covbadge.json - label: Coverage - message: ${{ env.total }}% - minColorRange: 50 - maxColorRange: 90 - valColorRange: ${{ env.total }} + # - name: "Make badge" + # uses: schneegans/dynamic-badges-action@v1.7.0 + # with: + # # GIST_TOKEN is a GitHub personal access token with scope "gist". + # auth: ${{ secrets.GIST_TOKEN }} + # gistID: 5f5c84f28e80b29f2f9ce92300859446 # replace with your real Gist id. + # filename: covbadge.json + # label: Coverage + # message: ${{ env.total }}% + # minColorRange: 50 + # maxColorRange: 90 + # valColorRange: ${{ env.total }} - name: Upload dummy files if: steps.test-with-pytest.conclusion != 'skipped' && matrix.enable-coverage == 'true' diff --git a/README.md b/README.md index 85acbac..332cf7a 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ pip install git@github.com:watakandai/specless.git curl -sSL https://install.python-poetry.org | python3 - ``` -### +### Install specless & dependencies ```bash # Clone locally @@ -50,9 +50,8 @@ cd specless # Activate the virtual environment python -m venv env source env/bin/activate -# Install +# Install specless & dependencies poetry install -# ``` Done!