From 0867d87b6de864edd2c53131f38b047dc3fb9910 Mon Sep 17 00:00:00 2001 From: Jeremy Klein Date: Mon, 5 Jun 2023 17:38:12 -0700 Subject: [PATCH 1/3] Add CI job for testing and publishing the python sdk --- .github/workflows/release.yaml | 33 ++++++++++++++++++++++++ .github/workflows/test.yaml | 46 ++++++++++++++++++++++++++++++++++ 2 files changed, 79 insertions(+) create mode 100644 .github/workflows/release.yaml create mode 100644 .github/workflows/test.yaml diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..5023809 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,33 @@ +name: "Release SDK" + +on: + release: + types: ["released"] + +jobs: + pypi-publish: + name: Upload release to PyPI + runs-on: ubuntu-latest + environment: + name: publish + url: https://pypi.org/p/lightspark + permissions: + id-token: write + steps: + - name: "Checkout" + uses: "actions/checkout@v3" + with: + fetch-depth: 10 + - name: "Setup Python" + uses: "actions/setup-python@v4" + with: + cache: "pipenv" + cache-dependency-path: "sdk/Pipfile.lock" + - name: "Install pipenv" + run: "pip install pipenv wheel" + - name: "Install dependencies" + run: "rm -rf $(pipenv --venv) && pipenv install --dev" + - name: "Build dist" + run: "pipenv run python setup.py sdist --format=zip" + - name: Publish package distributions to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml new file mode 100644 index 0000000..1fb72fb --- /dev/null +++ b/.github/workflows/test.yaml @@ -0,0 +1,46 @@ +name: "Python SDK test" + +on: + pull_request: + push: + branches: + - main + +jobs: + sdk-test: + runs-on: "ubuntu-22.04" + strategy: + matrix: + python_version: ["3.7", "3.10"] + steps: + - name: "Checkout" + uses: "actions/checkout@v3" + with: + fetch-depth: 10 + - name: "Setup Python" + uses: "actions/setup-python@v4" + with: + python-version: "${{ matrix.python_version }}" + cache: "pipenv" + cache-dependency-path: "sdk/Pipfile.lock" + - name: "Install pipenv" + run: "pip install pipenv wheel" + - name: "Install dependencies" + working-directory: "python-sdk" + run: "rm -rf $(pipenv --venv) && pipenv --python ${{ matrix.python_version }} install --dev" + - name: "Run pyre" + working-directory: "python-sdk" + run: | + set -o pipefail + pipenv run pyre | tee >(sed 's, ,:,' | awk -F: '{sub(" ", "", $5); print "::error file=" ENVIRON["PWD"] "/" $1 ",line=" $2 ",col=" $3 ",title=" $4 "::" $5}') + - name: "Run pytest" + working-directory: "python-sdk" + run: "PYTHONPATH=. pipenv run pytest" + - name: "Run pylint" + working-directory: "python-sdk" + run: "PYTHONPATH=. pipenv run pylint --jobs 0 --score n --msg-template='::{category} file={abspath},line={line},col={column},title={msg_id} {symbol}::{msg}' lightspark" + - name: "Run black" + working-directory: "python-sdk" + run: | + set -o pipefail + pipenv run black --check --diff . | tee >(pipenv run ../scripts/diff2annotation.py) From bd6c8ee9f6bf0690f1097d098b80d3396cff2dfd Mon Sep 17 00:00:00 2001 From: Jeremy Klein Date: Mon, 5 Jun 2023 17:42:22 -0700 Subject: [PATCH 2/3] Fix cache path --- .github/workflows/test.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 1fb72fb..a4af989 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -22,7 +22,7 @@ jobs: with: python-version: "${{ matrix.python_version }}" cache: "pipenv" - cache-dependency-path: "sdk/Pipfile.lock" + cache-dependency-path: "Pipfile.lock" - name: "Install pipenv" run: "pip install pipenv wheel" - name: "Install dependencies" From 946b255688d46451f076893b0cf2978b7d35e7e0 Mon Sep 17 00:00:00 2001 From: Jeremy Klein Date: Mon, 5 Jun 2023 17:44:32 -0700 Subject: [PATCH 3/3] Remove working dirs --- .github/workflows/test.yaml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index a4af989..bd219b1 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -26,21 +26,16 @@ jobs: - name: "Install pipenv" run: "pip install pipenv wheel" - name: "Install dependencies" - working-directory: "python-sdk" run: "rm -rf $(pipenv --venv) && pipenv --python ${{ matrix.python_version }} install --dev" - name: "Run pyre" - working-directory: "python-sdk" run: | set -o pipefail pipenv run pyre | tee >(sed 's, ,:,' | awk -F: '{sub(" ", "", $5); print "::error file=" ENVIRON["PWD"] "/" $1 ",line=" $2 ",col=" $3 ",title=" $4 "::" $5}') - name: "Run pytest" - working-directory: "python-sdk" run: "PYTHONPATH=. pipenv run pytest" - name: "Run pylint" - working-directory: "python-sdk" run: "PYTHONPATH=. pipenv run pylint --jobs 0 --score n --msg-template='::{category} file={abspath},line={line},col={column},title={msg_id} {symbol}::{msg}' lightspark" - name: "Run black" - working-directory: "python-sdk" run: | set -o pipefail pipenv run black --check --diff . | tee >(pipenv run ../scripts/diff2annotation.py)