name: Python Test on: workflow_dispatch: push: branches: - main # - develop paths: - 'src/**' - 'tests/**' - '.github/workflows/pytest.yml' - 'requirements.txt' - 'requirements-dev.txt' jobs: python-test: runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v3 - name: Set up Python uses: actions/setup-python@v4 with: python-version: "3.12" - name: Install dependencies id: installDependencies run: | pip install -r requirements.txt pip install -r requirements-dev.txt - name: Run Python Test id: runPyTest run: | pytest --junitxml=pytest.xml --cov-report term-missing --cov=src tests/ | tee pytest-coverage.txt - name: Coverage Report id: CoverageReport if: success() # テスト成功時のみ実行 run: | python - < README.md echo "" >> README.md echo "![test](coverage.svg)" >> README.md echo "" >> README.md cat coverage_table.md >> README.md cat README.md - name: Check files before upload id: checkFiles run: ls -l README.md coverage.svg - name: Commit Test Report To coverage-report Branch id: commitTestReport if: success() # テスト成功時のみ実行 run: | git config --global user.name "github-actions[bot]" git config --global user.email "github-actions[bot]@users.noreply.github.com" git add README.md coverage.svg git commit -m "Update coverage report" git push https://actions-bot:${{ secrets.CICD_GITEA_TOKEN }}@gitea.pglikers.com/data-science/cloud-run-job-base.git coverage-report --force