Initial #22
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: Lints-Tests-AWS | |
on: | |
push: | |
branches: | |
- main | |
- master | |
pull_request: | |
permissions: | |
contents: read | |
env: | |
RUSTFLAGS: -C debuginfo=0 # Do not produce debug symbols to keep memory usage down | |
CLOUD_BUCKET_NAME: "${{ secrets.CLOUD_BUCKET_NAME }}" | |
AWS_REGION: "${{ secrets.AWS_REGION }}" | |
PYTHON_VERSION: "3.11" | |
PACKAGE_NAME: "opsml_storage_s3" | |
MODULE_NAME: "PyS3FSStorageClient" | |
jobs: | |
rust-lints-test: | |
permissions: | |
id-token: write | |
contents: read | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: configure aws credentials | |
uses: aws-actions/configure-aws-credentials@v3 | |
with: | |
role-to-assume: ${{ secrets.AWS_ROLE_ARN }} | |
aws-region: ${{ env.AWS_REGION }} | |
- name: Set up Rust | |
run: rustup override set stable && rustup update | |
- name: Install clippy | |
run: rustup component add clippy | |
- name: Cache Rust | |
uses: Swatinem/rust-cache@v2 | |
- name: Run cargo clippy | |
working-directory: ./crates/opsml_storage | |
run: cargo clippy --workspace --all-targets -- -D warnings | |
- name: Tests | |
working-directory: ./crates/opsml_storage | |
run: make test.aws | |
env: | |
RUST_BACKTRACE: 1 | |
test-os: | |
name: test ${{ matrix.os }}-${{ matrix.python-version }} | |
permissions: | |
id-token: write | |
contents: read | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu, macos] | |
python-version: ["3.10", "3.11", "3.12"] # always run tests for latest 3 python versions | |
runs-on: ${{ matrix.os }}-latest | |
needs: [rust-lints-test] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: configure aws credentials | |
uses: aws-actions/configure-aws-credentials@v3 | |
with: | |
role-to-assume: ${{ secrets.AWS_ROLE_ARN }} | |
aws-region: ${{ env.AWS_REGION }} | |
- name: install rust stable | |
uses: dtolnay/rust-toolchain@stable | |
- name: cache rust | |
uses: Swatinem/rust-cache@v2 | |
with: | |
key: ${{ matrix.os }}-${{ matrix.python-version }}-v1 | |
- name: Set up uv | |
run: curl -LsSf https://astral.sh/uv/install.sh | sh | |
- name: set up python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Create virtual environment | |
working-directory: ./${{ env.PACKAGE_NAME }} | |
run: make setup.project | |
- name: Lints | |
working-directory: ./${{ env.PACKAGE_NAME }} | |
run: make lints.ci | |
- name: Run tests and report coverage | |
working-directory: ./${{ env.PACKAGE_NAME }} | |
run: make test.unit | |
test-macos-aarch64-build: | |
runs-on: macos-14 | |
needs: [rust-lints-test] | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ env.PYTHON_VERSION }} | |
architecture: arm64 | |
- name: "Build wheels - aarch64" | |
uses: PyO3/maturin-action@v1 | |
with: | |
target: aarch64 | |
args: --release --locked --out dist --interpreter ${{ env.PYTHON_VERSION }} | |
rust-toolchain: stable | |
working-directory: ./${{ env.PACKAGE_NAME }} | |
- name: "Test wheel - aarch64" | |
working-directory: ./${{ env.PACKAGE_NAME }} | |
run: | | |
python3 -m pip install opsml-storage-s3 --no-deps --no-index --force-reinstall --find-links dist | |
python -c "import ${{ env.PACKAGE_NAME }}" | |
test-linux-build: | |
runs-on: ubuntu-latest | |
needs: [rust-lints-test] | |
strategy: | |
matrix: | |
target: | |
- x86_64-unknown-linux-gnu | |
- i686-unknown-linux-gnu | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ env.PYTHON_VERSION }} | |
architecture: x64 | |
- name: "Build wheels" | |
uses: PyO3/maturin-action@v1 | |
with: | |
rust-toolchain: stable | |
working-directory: ./${{ env.PACKAGE_NAME }} | |
target: ${{ matrix.target }} | |
manylinux: auto | |
args: --release --locked --out dist --interpreter ${{ env.PYTHON_VERSION }} | |
# See: https://github.com/sfackler/rust-openssl/issues/2036#issuecomment-1724324145 | |
before-script-linux: | | |
# If we're running on rhel centos, install needed packages. | |
if command -v yum &> /dev/null; then | |
yum update -y && yum install -y perl-core openssl openssl-devel pkgconfig libatomic | |
# If we're running on i686 we need to symlink libatomic | |
# in order to build openssl with -latomic flag. | |
if [[ ! -d "/usr/lib64" ]]; then | |
ln -s /usr/lib/libatomic.so.1 /usr/lib/libatomic.so | |
fi | |
else | |
# If we're running on debian-based system. | |
apt update -y && apt-get install -y libssl-dev openssl pkg-config | |
fi | |
- name: "Test wheel" | |
if: ${{ startsWith(matrix.target, 'x86_64') }} | |
working-directory: ./${{ env.PACKAGE_NAME }} | |
run: | | |
python3 -m pip install opsml-storage-s3 --no-deps --no-index --force-reinstall --find-links dist | |
python -c "import ${{ env.PACKAGE_NAME }}" |