Skip to content

Commit

Permalink
add rust and update python
Browse files Browse the repository at this point in the history
  • Loading branch information
ss2165 committed Nov 26, 2024
1 parent 1ea772b commit 905cc45
Show file tree
Hide file tree
Showing 116 changed files with 23,106 additions and 145 deletions.
13 changes: 13 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[registries.artifactory]
index = "https://quantinuumsw.jfrog.io/artifactory/git/rust_local.git"

[net]
git-fetch-with-cli = true

# This allows building the type-check (pyo3) module on MacOSX "Apple Silicon"
# (cargo build from root directory ignores any config.toml in subdirectories.)
[target.aarch64-apple-darwin]
rustflags = [
"-C", "link-arg=-undefined",
"-C", "link-arg=dynamic_lookup",
]
19 changes: 19 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

**/target
**/.git
**/.venv
**/venv
**/.vscode
**/.pytest-cache
**/.mypy-cache
**/__pycache__
**/.direnv
**/.DS_Store
**/Thumbs.db

**/.ruff_cache
**/build
**/tests
**/Dockerfile
.env
cqcpython-secret.txt
162 changes: 162 additions & 0 deletions .github/workflows/build-typecheck.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
name: Build python

on:
workflow_dispatch

jobs:
build_core:
name: Build tierkreis package
runs-on: ubuntu-latest
defaults:
run:
working-directory: python
steps:
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install Protoc
uses: arduino/setup-protoc@v3

- name: build main package
run: |
pipx run build[uv] --installer=uv
- run: pipx twine check dist/*

- uses: actions/upload-artifact@v3
with:
name: core_build
path: python/dist

build_wheels:
name: build on ${{ matrix.platform || matrix.os }} (${{ matrix.target }} - ${{ matrix.manylinux || 'auto' }})
strategy:
fail-fast: false
matrix:
os: [ubuntu, macos, windows]
# os: [ubuntu]
target: [x86_64, aarch64]
# target: [x86_64]
manylinux: [auto]
include:
- os: ubuntu
platform: linux
- os: windows
ls: dir
- os: macos
target: aarch64


# - os: windows
# ls: dir
# target: i686
# python-architecture: x86
# - os: ubuntu
# platform: linux
# target: i686
# musllinux
# - os: ubuntu
# platform: linux
# target: x86_64
# manylinux: musllinux_1_1
# - os: ubuntu
# platform: linux
# target: aarch64
# manylinux: musllinux_1_1
exclude:
# Windows on arm64 only supports Python 3.11+
- os: windows
target: aarch64
runs-on: ${{ matrix.os }}-latest
steps:
- uses: actions/checkout@v3


- name: build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.target }}
manylinux: ${{ matrix.manylinux || 'auto' }}
container: ${{ matrix.container }}
args: --release --out dist --interpreter ${{ matrix.interpreter || '3.10 3.11 3.12' }} -m type_check/Cargo.toml
rust-toolchain: stable
rustup-components: "rustfmt"

- run: ${{ matrix.ls || 'ls -lh' }} dist/

- run: pipx twine check dist/*

- uses: actions/upload-artifact@v4
with:
name: type_wheels
path: dist


test_wheels:
needs: [build_core, build_wheels]
name: test on ${{ matrix.os }}-${{ matrix.arch }}-${{ matrix.python-version }}

strategy:
fail-fast: false
matrix:
os: [ubuntu, macos, windows]
python-version: ['3.10', '3.11', '3.12']
include:
- os: ubuntu
platform: manylinux
arch: x86_64
- os: windows
platform: win
arch: amd64
- os: macos
platform: macos
arch: x86_64

runs-on: ${{ matrix.os }}-latest
defaults:
run:
working-directory: python
steps:
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}

# - name: Setup tmate session
# uses: mxschmitt/action-tmate@v3


- name: Download core
uses: actions/download-artifact@v4
with:
name: core_build
path: python/dist/
- name: Install
run: |
pip install $(find dist -type f -iname "tierkreis-*.whl")'[docker,telemetry,commontypes,sc22-example]'
pip install pytest
shell: bash
- name: Test with pytest
run: |
pytest
- name: Download wheels
uses: actions/download-artifact@v4
with:
name: type_wheels
path: python/type_wheels/
- name: Install type_check
run: |
export PYVER=$(echo ${{ matrix.python-version }} | tr -d .)
export PLATFORM=${{ matrix.platform || matrix.os }}
export WHL=$(find type_wheels -type f -iname "tierkreis_typecheck*${PYVER}*-${PLATFORM}*${{ matrix.arch }}.whl")
pip install $WHL
shell: bash
- name: Test with pytest
run: |
pytest
65 changes: 65 additions & 0 deletions .github/workflows/deploy_docker_image.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Deploy Docker Image

on:
workflow_dispatch:
inputs:
image-tag:
required: true
type: string
aws-address:
type: string
default: '541083330167.dkr.ecr.us-west-2.amazonaws.com'
aws-repo-name:
type: string
default: 'tierkreis/runtime'
github-image-name:
type: string
default: tierkreis

env:
IMAGE_NAME: ${{ inputs.github-image-name }}

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Configure AWS credentials
run: |
aws configure set aws_access_key_id ${{ secrets.AWS_ACCESS_KEY_ID }}
aws configure set aws_secret_access_key ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws configure set region us-west-2
- name: Login to container registry
run: |
aws ecr get-login-password --region us-west-2 | docker login --username AWS --password-stdin ${{ inputs.aws-address }}
- name: Build and push docker image
run: |
DOCKER_BUILDKIT=1 docker build . \
-f ./tierkreis-server/Dockerfile \
--build-arg GIT_SHA=${{ github.sha }} \
-t ${{ inputs.aws-address }}/${{ inputs.aws-repo-name }}:${{ inputs.image-tag }}
echo ${{ inputs.aws-address }}/${{ inputs.aws-repo-name }}:${{ inputs.image-tag }}
docker push ${{ inputs.aws-address }}/${{ inputs.aws-repo-name }}:${{ inputs.image-tag }}
- name: List deployed images
run: aws ecr list-images --repository-name ${{ inputs.aws-repo-name }} --region us-west-2

- name: Log in to GitHub container registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin

- name: Build the Docker image
run: docker tag ${{ inputs.aws-address }}/${{ inputs.aws-repo-name }}:${{ inputs.image-tag }} $IMAGE_NAME

- name: Push the Docker image
run: |
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME
# Change all uppercase to lowercase
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
echo $IMAGE_ID
docker tag $IMAGE_NAME $IMAGE_ID:${{ inputs.image-tag }}
docker push $IMAGE_ID:${{ inputs.image-tag }}
6 changes: 6 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ concurrency:

jobs:
build:
defaults:
run:
working-directory: python
name: Build docs.
runs-on: ubuntu-latest
steps:
Expand All @@ -44,6 +47,9 @@ jobs:

publish:
name: Publish docs.
defaults:
run:
working-directory: python
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
Expand Down
9 changes: 9 additions & 0 deletions .github/workflows/pr_server_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"port": 8090,
"worker_path": [
{
"location": "python_nodes",
"path": "python/tests/test_worker"
}
]
}
Loading

0 comments on commit 905cc45

Please sign in to comment.