Skip to content

switch to use class modal for configurations #1228

switch to use class modal for configurations

switch to use class modal for configurations #1228

Workflow file for this run

name: Docker publish
on:
push:
# Publish `main` as Docker `latest` image.
branches:
- main
# Publish `v1.2.3` tags as releases.
tags:
- v*
# Run tests for any PRs.
pull_request:
branches: [main]
env:
IMAGE_NAME: thetagang
DOCKERHUB_ACCOUNT: brndnmtthws
DOCKER_BUILDKIT: 1
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12"]
poetry-version: ["1.4.0"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
id: setup-python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Cache ~/.cache/pip
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: python-${{ steps.setup-python.outputs.python-version }}
- name: Cache ~/.cache/pypoetry
uses: actions/cache@v4
with:
path: ~/.cache/pypoetry
key: python-${{ steps.setup-python.outputs.python-version }}-poetry-${{ hashFiles('poetry.lock') }}
- name: Install poetry
uses: abatilo/actions-poetry@v3
with:
poetry-version: ${{ matrix.poetry-version }}
- name: Install dependencies
run: |
poetry install
- name: Test with pytest
run: |
poetry run py.test
build-and-push:
needs: test
runs-on: ubuntu-latest
if: github.event_name == 'push'
steps:
- uses: actions/checkout@v4
- name: Cache TWS
id: cache-tws
uses: actions/cache@v4
env:
cache-name: cache-tws
with:
path: tws/
key: ${{ runner.os }}-publish-${{ env.cache-name }}-${{ hashFiles('extract-installer.sh') }}
- name: Extract TWS installer
if: steps.cache-tws.outputs.cache-hit != 'true'
run: ./extract-installer.sh
- name: Set up Python ${{ matrix.python-version }}
id: setup-python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Cache ~/.cache/pip
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: python-${{ steps.setup-python.outputs.python-version }}
- name: Cache ~/.cache/pypoetry
uses: actions/cache@v4
with:
path: ~/.cache/pypoetry
key: python-${{ steps.setup-python.outputs.python-version }}-poetry-${{ hashFiles('poetry.lock') }}
- name: Install poetry
uses: abatilo/actions-poetry@v3
with:
poetry-version: "1.4.0"
- name: Install dependencies
run: |
poetry install --only main --no-root
- name: Build package
run: |
poetry build
# Install the cosign tool except on PR
# https://github.com/sigstore/cosign-installer
- name: Install cosign
if: github.event_name != 'pull_request'
uses: sigstore/cosign-installer@main
with:
cosign-release: "v1.4.0"
- name: Set up QEMU
id: qemu
uses: docker/setup-qemu-action@v3
with:
image: tonistiigi/binfmt:latest
platforms: all
# Workaround: https://github.com/docker/build-push-action/issues/461
- name: Setup Docker buildx
uses: docker/setup-buildx-action@v3
# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Login to Docker Hub
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
username: ${{ github.actor }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ github.actor }}/${{ env.IMAGE_NAME }}
# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64,linux/arm64/v8
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
no-cache: ${{ startsWith(github.ref, 'refs/tags/') }}