Skip to content

Standardize linting and formatting #63

Standardize linting and formatting

Standardize linting and formatting #63

Workflow file for this run

name: build
# Build and test the NautilusTrader example data image
permissions: # Principle of least privilege
contents: read
on:
push:
branches: [main]
pull_request:
branches: ['*']
jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
# https://github.com/step-security/harden-runner
- uses: step-security/harden-runner@f4a75cfd619ee5ce8d5b864b0d183aff3c69b55a # v2.13.1
with:
egress-policy: audit
- name: Checkout repository
# https://github.com/actions/checkout
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
persist-credentials: false
- name: Set up Python
# https://github.com/actions/setup-python
uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0
with:
python-version: "3.13"
- name: Install uv
# https://github.com/astral-sh/setup-uv
uses: astral-sh/setup-uv@557e51de59eb14aaaba2ed9621916900a91d50c6 # v6.6.1
- name: Install dependencies
run: uv sync --all-groups
- name: Run pre-commit
run: uv run pre-commit run --all-files
docker-image:
runs-on: ubuntu-latest
needs:
- pre-commit
permissions:
contents: read
packages: write
steps:
# https://github.com/step-security/harden-runner
- uses: step-security/harden-runner@f4a75cfd619ee5ce8d5b864b0d183aff3c69b55a # v2.13.1
with:
egress-policy: audit
- name: Checkout repository
# https://github.com/actions/checkout
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
persist-credentials: false
- name: Set up QEMU
# https://github.com/docker/setup-qemu-action
uses: docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 # v3.6.0
- name: Set up Docker Buildx
# https://github.com/docker/setup-buildx-action
uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3.11.1
- name: Login to GHCR
if: github.event_name == 'push'
# https://github.com/docker/login-action
uses: docker/login-action@184bdaa0721073962dff0199f1fb9940f07167d1 # v3.5.0
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.PACKAGES_TOKEN }}
- name: Get branch name
id: branch-name
run: |
echo "current_branch=${GITHUB_REF#refs/heads/}" >> $GITHUB_OUTPUT
- name: Build and push Docker image
id: docker_build
# https://github.com/docker/build-push-action
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
with:
context: .
file: Dockerfile
# Multi-platform on push, single platform on PR (--load only supports one platform)
platforms: ${{ github.event_name == 'push' && 'linux/amd64,linux/arm64' || 'linux/amd64' }}
push: ${{ github.event_name == 'push' }}
tags: ghcr.io/${{ github.repository }}:${{ steps.branch-name.outputs.current_branch }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Image digest
if: github.event_name == 'push'
run: echo ${{ steps.docker_build.outputs.digest }}