Feat/tiktok #303
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
on: | |
push: | |
branches: | |
- main | |
tags: | |
- "*" | |
workflow_dispatch: {} | |
pull_request: | |
branches: | |
- main | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
env: | |
REGISTRY: ghcr.io | |
IMAGE_NAME: ${{ github.repository }} | |
jobs: | |
tests: | |
strategy: | |
matrix: | |
# I tried running stuff on macOS but it was too slow and unreliable. | |
# I also tried windows runners but couldn't get Docker to work there, so I gave up. | |
os: [ubuntu-latest] | |
python-version: ['3.10', '3.11', '3.12'] | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: install Microsoft ODBC | |
if: matrix.os == 'ubuntu-latest' | |
run: sudo ACCEPT_EULA=Y apt-get install msodbcsql18 -y | |
- name: install Microsoft ODBC | |
if: matrix.os == 'macos-13' | |
run: | | |
brew tap microsoft/mssql-release https://github.com/Microsoft/homebrew-mssql-release | |
brew update | |
HOMEBREW_ACCEPT_EULA=Y brew install msodbcsql18 | |
- name: Install Docker on macOS | |
if: matrix.os == 'macos-13' | |
run: | | |
brew install docker | |
brew install docker-compose | |
brew install colima | |
colima start | |
# Wait for Docker daemon to be ready | |
while ! docker system info > /dev/null 2>&1; do sleep 1; done | |
- name: install Microsoft ODBC | |
if: matrix.os == 'windows-latest' | |
run: | | |
Invoke-WebRequest -Uri https://go.microsoft.com/fwlink/?linkid=2249006 -OutFile msodbcsql.msi | |
Start-Process -FilePath "msiexec.exe" -ArgumentList "/i msodbcsql.msi /qn /norestart IACCEPTMSODBCSQLLICENSETERMS=YES" -Wait | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: install uv | |
uses: astral-sh/setup-uv@v3 | |
- name: Install pip dependencies | |
run: make deps-ci | |
- name: run tests (macOS) | |
if: matrix.os == 'macos-13' | |
run: make test-ci | |
env: | |
TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE: /var/run/docker.sock | |
DOCKER_HOST: unix:///Users/runner/.colima/docker.sock | |
- name: run tests (other OS) | |
if: matrix.os != 'macos-13' | |
run: make test-ci | |
- name: check the formatting | |
run: make lint-ci | |
build-and-push-image: | |
needs: tests | |
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/') | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Log in to the Container registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
platforms: linux/amd64,linux/arm64,linux/arm64/v8 | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max |