PBEsol as default for SOC (#951) #621
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: Build Docker image | |
on: | |
pull_request: | |
push: | |
branches: | |
- main | |
tags: | |
- v* | |
workflow_dispatch: | |
env: | |
FORCE_COLOR: 1 | |
IMAGE: ghcr.io/aiidalab/qe | |
BUILDKIT_PROGRESS: plain | |
# https://docs.github.com/en/actions/using-jobs/using-concurrency | |
concurrency: | |
# only cancel in-progress jobs or runs for the current workflow - matches against branch & tags | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
build-test-upload: | |
runs-on: ubuntu-latest | |
continue-on-error: true | |
steps: | |
- name: Checkout Repo ⚡️ | |
uses: actions/checkout@v4 | |
- name: Login to Container Registry 🔑 | |
uses: docker/login-action@v2 | |
if: ${{ !github.event.pull_request.head.repo.fork }} | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Docker meta 📝 | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: | | |
name=${{ env.IMAGE }} | |
tags: | | |
type=ref,event=pr | |
type=edge,enable={{is_default_branch}} | |
type=raw,value={{tag}},enable=${{ startsWith(github.ref, 'refs/tags/v') }} | |
- name: Build and push image | |
id: build-upload | |
uses: docker/build-push-action@v5 | |
with: | |
tags: ${{ steps.meta.outputs.tags }} | |
load: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork }} | |
push: ${{ ! (github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork) }} | |
context: . | |
platforms: linux/amd64 | |
cache-to: | | |
type=gha,scope=${{ github.workflow }},mode=min | |
cache-from: | | |
type=gha,scope=${{ github.workflow }} | |
- name: Set Up Python 🐍 | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.11 | |
- name: Install Dev Dependencies 📦 | |
run: pip install -r requirements-docker.txt | |
- name: Set jupyter token env | |
run: echo "JUPYTER_TOKEN=$(openssl rand -hex 32)" >> $GITHUB_ENV | |
- name: Run pytest for Chrome | |
run: pytest -sv --driver Chrome tests_integration/ | |
env: | |
# We'd like to identify the image by its unique digest, i.e ghcr.io/aiidalab/qe@sha256:<digest> | |
# but that sadly does not work when the image is loaded to Docker locally and not published on ghcr.io | |
# as is the case for PRs from forks. Hence this super-ugly ternary expression... | |
# For forks, we take the image as ghcr.io/aiidalab/qe:pr-XXX | |
# which is stored in the steps.meta.outputs.tags variable | |
QE_IMAGE: >- | |
${{ | |
github.event_name == 'pull_request' && | |
github.event.pull_request.head.repo.fork && | |
steps.meta.outputs.tags || | |
format('{0}@{1}', env.IMAGE, steps.build-upload.outputs.imageid) | |
}} | |
- name: Upload screenshots as artifacts | |
if: always() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: Screenshots | |
path: screenshots/ | |
if-no-files-found: error |