Merge pull request #171 from AutomatedProcessImprovement/control-flow… #155
This file contains hidden or 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, Test, Release | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: [ master ] | |
| paths: | |
| - 'src/simod/**' | |
| - 'tests/**' | |
| - '.github/workflows/**' | |
| - 'Dockerfile' | |
| - 'pyproject.toml' | |
| pull_request: | |
| branches: [ master ] | |
| paths: | |
| - 'src/simod/**' | |
| - 'tests/**' | |
| - '.github/workflows/**' | |
| - 'Dockerfile' | |
| env: | |
| DOCKERHUB_USERNAME: nokal | |
| DOCKERHUB_REPO: nokal/simod | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 120 | |
| strategy: | |
| matrix: | |
| python-version: [ '3.9' ] | |
| steps: | |
| - uses: actions/checkout@v3 | |
| with: | |
| fetch-depth: 0 | |
| - uses: actions/setup-python@v3 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - uses: actions/setup-java@v3 | |
| with: | |
| distribution: 'corretto' | |
| java-version: '8' | |
| - name: Install | |
| shell: bash | |
| run: | | |
| pip install poetry | |
| poetry install | |
| - name: Test | |
| shell: bash | |
| run: poetry run pytest --cov=. --cov-report=xml --durations=0 -v -x -k "not test_build_fuzzy_calendars and not test_bpic15 and not test_missing_activities_repaired" -m "not benchmark" | |
| - name: PyLint | |
| shell: bash | |
| run: poetry run pylint -j 0 --exit-zero src/simod > pylint.txt | |
| - name: Upload PyLint output | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: pylint.txt | |
| path: ./pylint.txt | |
| - name: Upload coverage to Codecov | |
| uses: codecov/codecov-action@v2 | |
| with: | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| files: ./coverage.xml | |
| env_vars: OS,PYTHON | |
| fail_ci_if_error: false | |
| name: codecov-umbrella | |
| verbose: true | |
| build-and-publish-images: | |
| runs-on: ubuntu-latest | |
| needs: [ test ] | |
| timeout-minutes: 120 | |
| if: github.ref == 'refs/heads/master' | |
| outputs: | |
| version: ${{ steps.versioning.outputs.version }} | |
| docker_image: ${{ env.DOCKERHUB_REPO }}:${{ steps.versioning.outputs.version }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v3 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v1 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v1 | |
| - name: Login to DockerHub | |
| uses: docker/login-action@v1 | |
| with: | |
| username: ${{ env.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Get the version | |
| id: versioning | |
| run: | | |
| pip install poetry | |
| echo "version=$(poetry version --short)" >> "$GITHUB_OUTPUT" | |
| - name: Build and push to DockerHub | |
| uses: docker/build-push-action@v2 | |
| with: | |
| push: true | |
| tags: ${{ env.DOCKERHUB_REPO }}:latest,${{ env.DOCKERHUB_REPO }}:${{ steps.versioning.outputs.version }} | |
| file: Dockerfile | |
| context: . | |
| platforms: linux/amd64,linux/arm64 | |
| release-pypi: | |
| name: Release, Python ${{ matrix.python-version }} | |
| needs: [ test ] | |
| runs-on: ubuntu-latest | |
| if: github.ref == 'refs/heads/master' | |
| strategy: | |
| matrix: | |
| python-version: [ '3.9' ] | |
| environment: | |
| name: PyPI | |
| url: https://pypi.org/p/simod | |
| permissions: | |
| id-token: write | |
| contents: write | |
| packages: write | |
| steps: | |
| - uses: actions/checkout@v3 | |
| with: | |
| fetch-depth: 0 | |
| - uses: actions/setup-python@v3 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| architecture: x64 | |
| - name: Install poetry | |
| shell: bash | |
| run: pip install poetry | |
| - name: Install project | |
| run: | | |
| poetry install | |
| - name: Build | |
| run: | | |
| poetry build | |
| - name: Get version | |
| id: get_version | |
| run: | | |
| echo "version=$(poetry version --short)" >> "$GITHUB_OUTPUT" | |
| - name: Upload artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: simod-${{ steps.get_version.outputs.version }}-py${{ matrix.python-version }} | |
| path: dist | |
| - name: Generate changelog | |
| run: | | |
| echo "# Changelog" > CHANGELOG.md | |
| echo "" >> CHANGELOG.md | |
| echo "\`\`\`" >> CHANGELOG.md | |
| git log --pretty=format:"%h - %s (%an)" $(git describe --tags --abbrev=0)..HEAD >> CHANGELOG.md | |
| echo "" >> CHANGELOG.md | |
| echo "\`\`\`" >> CHANGELOG.md | |
| - name: Assign repository tag | |
| run: | | |
| git tag ${{ steps.get_version.outputs.version }} | |
| git push --tags | |
| - name: Create release | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| files: | | |
| dist/* | |
| tag_name: ${{ steps.get_version.outputs.version }} | |
| body_path: CHANGELOG.md | |
| - name: Publish to PyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 |