diff --git a/.github/workflows/ci.yml b/.github/workflows/docker.yml similarity index 65% rename from .github/workflows/ci.yml rename to .github/workflows/docker.yml index 0c64b8c..15ae3b9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/docker.yml @@ -3,7 +3,7 @@ # Publishes Docker images to Github Container Repository (ghcr.io), # and runs the automated tests with pytest. -name: CI +name: Docker on: push: @@ -21,7 +21,7 @@ jobs: build: - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 timeout-minutes: 20 permissions: packages: write @@ -37,36 +37,30 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Docker meta - id: meta - uses: docker/metadata-action@v5 - with: - images: ${{ env.REGISTRY }}${{ env.ISPG_IMAGE }} - # Before tests pass, we tag the image by the branch name - # or by pull request number, e.g. pr-11 - # https://github.com/docker/metadata-action#tags-input - # See the release workflow for the release tags. - tags: | - type=sha - type=ref,event=pr + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 - name: Build image id: build uses: docker/build-push-action@v5 with: - tags: ${{ steps.meta.outputs.tags }} - push: true + tags: ${{ env.REGISTRY }}${{ env.ISPG_IMAGE }} + cache-from: type=gha + cache-to: type=gha,mode=max + outputs: | + type=registry,push-by-digest=true,name-canonical=true test: needs: build - runs-on: ubuntu-latest - timeout-minutes: 10 + runs-on: ubuntu-22.04 + timeout-minutes: 20 permissions: packages: read contents: read steps: - uses: actions/checkout@v4 + - name: Login to GitHub Container Registry uses: docker/login-action@v3 with: @@ -74,11 +68,16 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Setup Python test environment - uses: mamba-org/setup-micromamba@v1 + - name: Set up Python + uses: actions/setup-python@v5 with: - environment-file: environment.yml - cache-environment: true + python-version: '3.12' + + - name: Install uv + run: curl --proto '=https' --tlsv1.2 -LsSf https://github.com/astral-sh/uv/releases/download/0.1.43/uv-installer.sh | sh + + - name: Install test requirements + run: uv pip install --system -r requirements.txt --no-deps - name: Run tests shell: bash -l {0} # required to activate the conda environment @@ -87,22 +86,16 @@ jobs: # Image that was build in the build workflow ISPG_IMAGE: ${{ env.ISPG_IMAGE }}@${{ needs.build.outputs.image_digest }} - release: - if: >- - github.repository_owner == 'ispg-group' - && (github.ref_type == 'tag' || github.ref_name == 'main') - needs: - - build - - test + release-ghcr: + needs: [build, test] + runs-on: ubuntu-22.04 permissions: packages: write contents: write - runs-on: ubuntu-latest - timeout-minutes: 10 - steps: - uses: actions/checkout@v4 - - name: Login to GitHub Container Registry + + - name: Login to GitHub Container Registry 🔑 uses: docker/login-action@v3 with: registry: ghcr.io @@ -115,11 +108,11 @@ jobs: with: images: ${{ env.REGISTRY }}${{ env.ISPG_IMAGE }} tags: | - type=edge - type=raw,value={{tag}},enable=${{ github.ref_type == 'tag' && ! startsWith(github.ref_name, 'v') }} + type=ref,event=pr + type=edge,enable={{is_default_branch}} type=match,pattern=v(\d{4}\.\d{2}.\d+(-.+)?),group=1 - - name: Release image + - name: Push image uses: akhilerm/tag-push-action@v2.2.0 with: src: ${{ env.REGISTRY }}${{ env.ISPG_IMAGE }}@${{ needs.build.outputs.image_digest }} diff --git a/Dockerfile b/Dockerfile index f621b9c..24b2e39 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM aiidalab/full-stack:latest +FROM aiidalab/full-stack:aiida-2.4.3 LABEL maintainer="Daniel Hollas " USER root diff --git a/environment.yml b/environment.yml deleted file mode 100644 index 1e66ca9..0000000 --- a/environment.yml +++ /dev/null @@ -1,13 +0,0 @@ ---- -name: aiidalab-ispg-docker-stack -channels: - - conda-forge -dependencies: - - bumpver=2023.1129 - - docker-compose=1.29.2 - - pip - - pytest=7.4.4 - - python=3.11 - - requests=2.31.0 - - pip: - - pytest-docker==2.0.1 diff --git a/requirements.in b/requirements.in new file mode 100644 index 0000000..77291fe --- /dev/null +++ b/requirements.in @@ -0,0 +1,3 @@ +pytest~=7.4 +pytest-docker +requests diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..8318f99 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,26 @@ +# This file was autogenerated by uv via the following command: +# uv pip compile requirements.in +attrs==23.2.0 + # via pytest-docker +certifi==2024.2.2 + # via requests +charset-normalizer==3.3.2 + # via requests +idna==3.7 + # via requests +iniconfig==2.0.0 + # via pytest +packaging==24.0 + # via pytest +pluggy==1.5.0 + # via pytest +pytest==7.4.4 + # via + # -r requirements.in + # pytest-docker +pytest-docker==3.1.1 + # via -r requirements.in +requests==2.31.0 + # via -r requirements.in +urllib3==2.2.1 + # via requests