⬆️ Bump ruff from 0.8.0 to 0.8.1 in the dependencies group #16
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: Python Test | |
on: | |
pull_request: | |
branches: | |
- 'main' | |
paths: | |
- 'json2vars_setter/**' | |
- 'tests/**' | |
- 'pyproject.toml' | |
- 'poetry.lock' | |
- 'requirements-dev.txt' | |
- 'requirements.txt' | |
- '.github/workflows/python_test.yml' | |
jobs: | |
set_variables: | |
runs-on: ubuntu-latest | |
outputs: | |
os: ${{ steps.json2vars.outputs.os }} | |
versions_python: ${{ steps.json2vars.outputs.versions_python }} | |
ghpages_branch: ${{ steps.json2vars.outputs.ghpages_branch }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4.2.2 | |
with: | |
fetch-depth: 0 | |
- name: Set variables from JSON | |
id: json2vars | |
uses: 7rikazhexde/json2vars-setter@main | |
with: | |
#json-file: .github/workflows/matrix.json | |
json-file: .github/workflows/python_project_matrix.json | |
- name: Debug output values | |
run: | | |
echo "os: ${{ steps.json2vars.outputs.os }}" | |
echo "os[0]: ${{ fromJson(steps.json2vars.outputs.os)[0] }}" | |
echo "os[1]: ${{ fromJson(steps.json2vars.outputs.os)[1] }}" | |
echo "os[2]: ${{ fromJson(steps.json2vars.outputs.os)[2] }}" | |
echo "versions_python: ${{ steps.json2vars.outputs.versions_python }}" | |
echo "versions_python[0]: ${{ fromJson(steps.json2vars.outputs.versions_python)[0] }}" | |
echo "versions_python[1]: ${{ fromJson(steps.json2vars.outputs.versions_python)[1] }}" | |
echo "versions_python[2]: ${{ fromJson(steps.json2vars.outputs.versions_python)[2] }}" | |
echo "versions_python[3]: ${{ fromJson(steps.json2vars.outputs.versions_python)[3] }}" | |
echo "ghpages_branch: ${{ steps.json2vars.outputs.ghpages_branch }}" | |
run_tests: | |
needs: set_variables | |
strategy: | |
matrix: | |
os: ${{ fromJson(needs.set_variables.outputs.os) }} | |
python-version: ${{ fromJson(needs.set_variables.outputs.versions_python) }} | |
runs-on: ${{ matrix.os }} | |
outputs: | |
test_status: ${{ steps.set_status.outputs.status }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4.2.2 | |
with: | |
fetch-depth: 0 | |
- name: Set up Python | |
uses: actions/setup-python@v5.3.0 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Set timezone | |
uses: szenius/set-timezone@v2.0 | |
with: | |
timezoneLinux: "Asia/Tokyo" | |
timezoneMacos: "Asia/Tokyo" | |
timezoneWindows: "Tokyo Standard Time" | |
- name: Install poetry | |
run: | | |
pip install poetry | |
echo "Poetry version: $(poetry --version)" | |
- name: Cache dependencies | |
uses: actions/cache@v4.1.2 | |
with: | |
path: ~/.cache/pypoetry | |
key: ${{ runner.os }}-poetry-${{ hashFiles('**/poetry.lock') }} | |
- name: Install dependencies | |
run: | | |
poetry install | |
echo "Installed dependencies:" | |
poetry show --tree | |
- name: Show matrix | |
shell: bash | |
run: | | |
# For non-list case | |
ghpages_branch="${{ needs.set_variables.outputs.ghpages_branch }}" | |
# For list case, explicitly enclose the list in “” to make it a string. (Note that it is not ''.) | |
os='${{ needs.set_variables.outputs.os }}' | |
versions_python='${{ needs.set_variables.outputs.versions_python }}' | |
# For list index case | |
os_0="${{ fromJson(needs.set_variables.outputs.os)[0] }}" | |
os_1="${{ fromJson(needs.set_variables.outputs.os)[1] }}" | |
os_2="${{ fromJson(needs.set_variables.outputs.os)[2] }}" | |
versions_python_0="${{ fromJson(needs.set_variables.outputs.versions_python)[0] }}" | |
versions_python_1="${{ fromJson(needs.set_variables.outputs.versions_python)[1] }}" | |
versions_python_2="${{ fromJson(needs.set_variables.outputs.versions_python)[2] }}" | |
versions_python_3="${{ fromJson(needs.set_variables.outputs.versions_python)[3] }}" | |
echo "os: ${os}" | |
echo "os_0: ${os_0}" | |
echo "os_1: ${os_1}" | |
echo "os_2: ${os_2}" | |
echo "versions_python: ${versions_python}" | |
echo "versions_python_0: ${versions_python_0}" | |
echo "versions_python_1: ${versions_python_1}" | |
echo "versions_python_2: ${versions_python_2}" | |
echo "versions_python_3: ${versions_python_3}" | |
echo "ghpages_branch: ${ghpages_branch}" | |
# For loop case | |
os_list=$(echo "${os}" | jq -r '.[]' | tr '\n' ' ' | sed 's/ $//') | |
python_versions_list=$(echo "${versions_python}" | jq -r '.[]' | tr '\n' ' ' | sed 's/ $//') | |
for current_os in ${os_list}; do | |
for version in ${python_versions_list}; do | |
echo "Current OS: ${current_os}, Current Python Version: ${version}" | |
done | |
done | |
- name: Run pytest | |
id: pytest | |
continue-on-error: true | |
shell: bash | |
run: | | |
poetry run pytest | |
- name: Set test status | |
id: set_status | |
if: always() | |
shell: bash | |
run: | | |
if [ "${{ job.status }}" == "cancelled" ]; then | |
echo "status=cancelled" >> "$GITHUB_OUTPUT" | |
elif [ "${{ job.status }}" == "skipped" ]; then | |
echo "status=skipped" >> "$GITHUB_OUTPUT" | |
elif [ "${{ steps.pytest.outcome }}" == "failure" ]; then | |
echo "status=failing" >> "$GITHUB_OUTPUT" | |
elif [ "${{ steps.pytest.outcome }}" == "success" ]; then | |
echo "status=passing" >> "$GITHUB_OUTPUT" | |
else | |
echo "status=pending" >> "$GITHUB_OUTPUT" | |
fi | |
update_badge: | |
needs: run_tests | |
runs-on: ubuntu-latest | |
if: always() | |
steps: | |
- name: Set color | |
id: set_color | |
shell: bash | |
run: | | |
status="${{ needs.run_tests.outputs.test_status }}" | |
if [ "$status" == "passing" ]; then | |
echo "color=2ea44f" >> "$GITHUB_OUTPUT" | |
elif [ "$status" == "failing" ]; then | |
echo "color=cf222e" >> "$GITHUB_OUTPUT" | |
elif [ "$status" == "pending" ]; then | |
echo "color=dbab09" >> "$GITHUB_OUTPUT" | |
else | |
echo "color=808080" >> "$GITHUB_OUTPUT" | |
fi | |
- name: Create badge | |
uses: schneegans/dynamic-badges-action@v1.7.0 | |
with: | |
auth: ${{ secrets.GIST_TOKEN }} | |
gistID: 26cb492ab0cfff920c516a622b2bfa44 | |
filename: python-test-badge.json | |
label: Python Test | |
message: ${{ needs.run_tests.outputs.test_status }} | |
color: ${{ steps.set_color.outputs.color }} | |
labelColor: "24292f" | |
style: "flat" | |
namedLogo: "github" | |
logoColor: "white" |