Workflow file for this run
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: Push to O2K | |
on: [push] | |
permissions: | |
id-token: write # This is required for requesting the JWT | |
contents: read # This is required for actions/checkout | |
issues: write # permits an action to add a comment to an issue. | |
pull-requests: write | |
jobs: | |
update-leap-model-parser: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Extract branch name | |
id: extract_branch | |
run: echo "::set-output name=branch_name::$(echo ${GITHUB_REF#refs/heads/})" | |
- name: Check out repository | |
uses: actions/checkout@v2 | |
- name: Get package version from pyproject.toml | |
id: package_version | |
run: | | |
PACKAGE_VERSION=$(awk -F' = ' '$1 == "version" {gsub(/"/, "", $2); print $2}' pyproject.toml | head -n 1) | |
echo "PACKAGE_VERSION=$PACKAGE_VERSION" >> $GITHUB_ENV | |
echo "$PACKAGE_VERSION" | |
- name: Set up python | |
id: setup-python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: 3.8.12 | |
- name: Set Poetry Lock Hash | |
run: | | |
echo "POETRY_HASH=$(sha256sum poetry.lock | cut -d ' ' -f 1)" >> $GITHUB_ENV | |
- name: Install Poetry | |
uses: snok/install-poetry@v1 | |
with: | |
version: 1.8.2 | |
virtualenvs-create: true | |
virtualenvs-in-project: true | |
installer-parallel: true | |
- name: Load cached venv | |
id: cached-poetry-dependencies | |
uses: actions/cache@v2 | |
with: | |
path: .venv | |
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ env.POETRY_HASH }} | |
- name: Install dependencies | |
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' | |
run: poetry install --no-interaction --no-root | |
- name: Check if version exists on PyPI | |
id: check_version | |
run: | | |
URL="https://pypi.org/pypi/onnx2kerastl/$PACKAGE_VERSION/json" | |
echo "URL: $URL" | |
RESPONSE=$(curl -s -o /dev/null -w "%{http_code}" "$URL") | |
if [ $RESPONSE -eq 200 ]; then | |
echo "Version $PACKAGE_VERSION already exists on PyPI." | |
echo "IS_O2K_PUBLISHED=true" >> $GITHUB_ENV | |
else | |
echo "Version $PACKAGE_VERSION does not exist on PyPI." | |
echo "IS_O2K_PUBLISHED=false" >> $GITHUB_ENV | |
fi | |
- name: Build and publish package | |
if: success() # Only run this step if the previous steps were successful | |
run: | | |
if [ "$IS_O2K_PUBLISHED" != "true" ]; then | |
poetry build | |
poetry publish -u __token__ -p ${{ secrets.PYPI_O2K }} | |
echo "Published O2K version $PACKAGE_VERSION" | |
else | |
echo "Skipping publishing as version already exists on PyPI." | |
fi | |
- name: Ensure folder exists | |
run: mkdir -p leap_parser_tests_copy # Ensure the folder exists if it doesn't already | |
- name: Copy leap_model_tests from onnx2keras | |
run: cp -r $GITHUB_WORKSPACE/leap_parser_tests /home/runner/work/leap_parser_tests_copy | |
- name: checkout leap model parser | |
uses: actions/checkout@v4 | |
with: | |
token: ${{ secrets.TENSORLEAP_OPS_GITHUB_TOKEN }} | |
repository: tensorleap/leap-model-parser | |
path: leap-model-parser | |
- name: Configure AWS Credentials | |
uses: aws-actions/[email protected] | |
with: | |
role-to-assume: arn:aws:iam::898022457080:role/TerraformAdmin | |
aws-region: us-east-1 | |
- name: leap-model-parser testing | |
working-directory: leap-model-parser | |
env: | |
PYTHONPATH: ${{ env.PYTHONPATH }}:${{ github.workspace }}/leap-model-parser | |
run: | #fetch or create branch, update-o2k-version | |
echo "Project version is $PACKAGE_VERSION" | |
BRANCH="${{ steps.extract_branch.outputs.branch_name }}-from-o2k" | |
git config user.email [email protected] | |
git config user.name github-actions | |
if git ls-remote --exit-code --heads origin "$BRANCH" >/dev/null 2>&1; then | |
git fetch origin "$BRANCH" | |
git checkout "$BRANCH" | |
else | |
git checkout -b "$BRANCH" | |
fi | |
ls | |
pwd | |
poetry add onnx2kerastl==$PACKAGE_VERSION | |
find /home/runner/work/leap_parser_tests_copy -type f -exec sh -c 'cp -v "$1" "$GITHUB_WORKSPACE/leap-model-parser/tests/$(basename "$1")"' _ {} \; | |
source .venv/bin/activate | |
cd tests | |
ls | |
pytest -s test_branch_model.py --cloud_dir clip --model_name clip.onnx | |
echo "1" | |
rm -rf /home/runner/work/leap_parser_tests_copy # Example command: List files in the checked-out repositor | |
# poetry add -u | |
# poetry commit -m "update O2K version" | |
# git push origin "$BRANCH" | |