[pre-commit.ci] pre-commit autoupdate #502
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: Pytest, build docker image, push to GHCR | |
| on: [pull_request, push] | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.head_ref }} | |
| cancel-in-progress: true | |
| env: | |
| # https://github.com/pytest-dev/pytest/issues/2042#issuecomment-429289164 | |
| PY_IGNORE_IMPORTMISMATCH: 1 | |
| jobs: | |
| pytest: | |
| strategy: | |
| matrix: | |
| os: [ubuntu-latest, macos-14] | |
| fail-fast: true | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup pixi | |
| uses: prefix-dev/setup-pixi@v0.8.1 | |
| with: | |
| environments: test | |
| cache: true | |
| - name: Enable numba boundscheck for better error catching | |
| run: | | |
| echo "NUMBA_BOUNDSCHECK=1" >> $GITHUB_ENV | |
| echo "TQDM_DISABLE=1" >> $GITHUB_ENV | |
| - name: Test | |
| run: pixi run -e test pytest -n0 -vv | |
| dockerize: # Based on Mintpy: https://github.com/insarlab/MintPy/blob/5ca554fef324b816f9130feec567e2cf463e41d2/.github/workflows/build-n-publish-to-pypi.yml | |
| name: Build Docker image and push to GitHub Container Registry | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v3 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Python 3.11 | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.11' | |
| - name: Set environment variables for docker build | |
| run: | | |
| pip install setuptools_scm # Install setuptools_scm to get version number | |
| # Save version number from CLI | |
| version=$(python -m setuptools_scm) | |
| sanitized_version=${version//+/-} # Replace all '+' with '-' | |
| echo "SWEETS_VERSION=${sanitized_version}" >> $GITHUB_ENV | |
| - name: Login to GitHub Container Registry | |
| uses: docker/login-action@v2 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build, tag, and push image to Github Container Registry | |
| uses: docker/build-push-action@v4 | |
| with: | |
| context: . | |
| file: Dockerfile | |
| push: ${{ github.event_name != 'pull_request' }} | |
| tags: | | |
| ghcr.io/${{ github.repository }}:${{ env.SWEETS_VERSION }} | |
| labels: | | |
| org.opencontainers.image.created=${{ env.CI_JOB_TIMESTAMP }} | |
| org.opencontainers.image.version=${{ env.SWEETS_VERSION }} | |
| org.opencontainers.image.revision=${{ github.sha }} | |
| - name: Add develop tag | |
| if: github.ref == 'refs/heads/main' | |
| uses: akhilerm/tag-push-action@v2.1.0 | |
| with: | |
| src: ghcr.io/${{ github.repository }}:${{ env.SWEETS_VERSION }} | |
| dst: ghcr.io/${{ github.repository }}:develop | |
| - name: Add latest tag | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| uses: akhilerm/tag-push-action@v2.1.0 | |
| with: | |
| src: ghcr.io/${{ github.repository }}:${{ env.SWEETS_VERSION }} | |
| dst: ghcr.io/${{ github.repository }}:latest |