From 298d4c7fb6d1747816378590ca710d39b649536f Mon Sep 17 00:00:00 2001 From: Manuel Lopez Date: Tue, 2 May 2023 01:11:45 +0000 Subject: [PATCH 01/15] ensure-pnpm action --- actions/ensure-pnpm/README.md | 4 ++++ actions/ensure-pnpm/action.yaml | 21 +++++++++++++++++++++ actions/ensure-pnpm/ensure-pnpm.sh | 16 ++++++++++++++++ 3 files changed, 41 insertions(+) create mode 100644 actions/ensure-pnpm/README.md create mode 100644 actions/ensure-pnpm/action.yaml create mode 100755 actions/ensure-pnpm/ensure-pnpm.sh diff --git a/actions/ensure-pnpm/README.md b/actions/ensure-pnpm/README.md new file mode 100644 index 00000000..e431cee3 --- /dev/null +++ b/actions/ensure-pnpm/README.md @@ -0,0 +1,4 @@ +# m ensure-pnpm action + +This action ensures that pnpm is installed and caches the pnpm store for the +given hash of all the pnpm-lock files in the project. diff --git a/actions/ensure-pnpm/action.yaml b/actions/ensure-pnpm/action.yaml new file mode 100644 index 00000000..b5a0e57d --- /dev/null +++ b/actions/ensure-pnpm/action.yaml @@ -0,0 +1,21 @@ +name: 'm ensure-pnpm' +description: 'ensure that pnpm is installed and cache the store' +inputs: + pnpm-version: + description: pnpm version to install + default: latest + required: false +runs: + using: 'composite' + steps: + - name: ensure pnpm + id: pnpm-cache + shell: bash + run: ${GITHUB_ACTION_PATH}/ensure-pnpm.sh ${{ inputs.pnpm-version }} + + - name: Setup pnpm cache + uses: actions/cache@v3 + with: + path: ${{ steps.pnpm-cache.outputs.store-path }} + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: ${{ runner.os }}-pnpm-store- diff --git a/actions/ensure-pnpm/ensure-pnpm.sh b/actions/ensure-pnpm/ensure-pnpm.sh new file mode 100755 index 00000000..88cbae42 --- /dev/null +++ b/actions/ensure-pnpm/ensure-pnpm.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +pnpmVersion="${1:-latest}" + +set -exuo pipefail + +pnpmPath=$(which pnpm || echo '') +if [ "$pnpmPath" == '' ]; then + if [ "$pnpmVersion" == 'latest' ]; then + npm install -g pnpm + else + npm install -g "pnpm@$pnpmVersion" + fi +fi + +echo "store-path=$(pnpm store path)" >> $GITHUB_OUTPUT From 01526c4ceca0bff092f7befaa144898d4fa654bc Mon Sep 17 00:00:00 2001 From: Manuel Lopez Date: Tue, 2 May 2023 02:04:34 +0000 Subject: [PATCH 02/15] testing venv action --- actions/ensure-poetry/action.yaml | 26 ++++++++++++++++++++++++++ actions/ensure-poetry/ensure-poetry.sh | 22 ++++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 actions/ensure-poetry/action.yaml create mode 100755 actions/ensure-poetry/ensure-poetry.sh diff --git a/actions/ensure-poetry/action.yaml b/actions/ensure-poetry/action.yaml new file mode 100644 index 00000000..c2322422 --- /dev/null +++ b/actions/ensure-poetry/action.yaml @@ -0,0 +1,26 @@ +name: 'm ensure-poetry' +description: 'ensure that poetry is installed and cache the venv' +inputs: + poetry-version: + description: poetry version to install + default: latest + required: false +runs: + using: 'composite' + steps: + - name: ensure poetry + id: venv-cache + shell: bash + run: ${GITHUB_ACTION_PATH}/ensure-poetry.sh ${{ inputs.poetry-version }} + + - name: Setup venv cache + uses: actions/cache@v3 + with: + path: /opt/venv + key: ${{ runner.os }}-venv-${{ hashFiles('**/poetry.lock') }} + restore-keys: ${{ runner.os }}-venv- + + - name: Setup venv + shell: bash + run: | + python3 -m venv /opt/venv/workspace diff --git a/actions/ensure-poetry/ensure-poetry.sh b/actions/ensure-poetry/ensure-poetry.sh new file mode 100755 index 00000000..41140c87 --- /dev/null +++ b/actions/ensure-poetry/ensure-poetry.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +poetryVersion="${1:-latest}" + +set -exuo pipefail + +poetryPath=$(which poetry || echo '') +if [ "$poetryPath" == '' ]; then + if [ "$poetryVersion" == 'latest' ]; then + pip install poetry==$poetryVersion + else + pip install poetry==$poetryVersion + fi +fi + +{ + echo "POETRY_HOME=/opt/venv/poetry" + echo "POETRY_CACHE_DIR=/opt/venv/.cache/pypoetry" + echo "VIRTUAL_ENV=/opt/venv/workspace" +} >> "$GITHUB_ENV" + +echo "/opt/venv/workspace/bin" >> $GITHUB_PATH From c0d8ae7ab5baa4c559e90409b9c4ea3b724d6a43 Mon Sep 17 00:00:00 2001 From: Manuel Lopez Date: Tue, 2 May 2023 02:14:55 +0000 Subject: [PATCH 03/15] do not specify version --- actions/ensure-poetry/ensure-poetry.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/actions/ensure-poetry/ensure-poetry.sh b/actions/ensure-poetry/ensure-poetry.sh index 41140c87..aed57add 100755 --- a/actions/ensure-poetry/ensure-poetry.sh +++ b/actions/ensure-poetry/ensure-poetry.sh @@ -7,9 +7,9 @@ set -exuo pipefail poetryPath=$(which poetry || echo '') if [ "$poetryPath" == '' ]; then if [ "$poetryVersion" == 'latest' ]; then - pip install poetry==$poetryVersion + pip install poetry else - pip install poetry==$poetryVersion + pip install "poetry==$poetryVersion" fi fi From a93a21932f4f64a21fa30a85eceadd006d24a80c Mon Sep 17 00:00:00 2001 From: Manuel Lopez Date: Tue, 2 May 2023 02:25:56 +0000 Subject: [PATCH 04/15] save poetry in the venv --- actions/ensure-poetry/action.yaml | 11 +++-------- actions/ensure-poetry/ensure-poetry.sh | 3 +++ 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/actions/ensure-poetry/action.yaml b/actions/ensure-poetry/action.yaml index c2322422..b4c35346 100644 --- a/actions/ensure-poetry/action.yaml +++ b/actions/ensure-poetry/action.yaml @@ -8,11 +8,6 @@ inputs: runs: using: 'composite' steps: - - name: ensure poetry - id: venv-cache - shell: bash - run: ${GITHUB_ACTION_PATH}/ensure-poetry.sh ${{ inputs.poetry-version }} - - name: Setup venv cache uses: actions/cache@v3 with: @@ -20,7 +15,7 @@ runs: key: ${{ runner.os }}-venv-${{ hashFiles('**/poetry.lock') }} restore-keys: ${{ runner.os }}-venv- - - name: Setup venv + - name: ensure poetry + id: venv-cache shell: bash - run: | - python3 -m venv /opt/venv/workspace + run: ${GITHUB_ACTION_PATH}/ensure-poetry.sh ${{ inputs.poetry-version }} diff --git a/actions/ensure-poetry/ensure-poetry.sh b/actions/ensure-poetry/ensure-poetry.sh index aed57add..be49e666 100755 --- a/actions/ensure-poetry/ensure-poetry.sh +++ b/actions/ensure-poetry/ensure-poetry.sh @@ -4,6 +4,9 @@ poetryVersion="${1:-latest}" set -exuo pipefail +python3 -m venv /opt/venv/workspace +. /opt/venv/workspace/bin/activate + poetryPath=$(which poetry || echo '') if [ "$poetryPath" == '' ]; then if [ "$poetryVersion" == 'latest' ]; then From aee6ba48bcecb5eb760c46f8f2fcd80ef0b7d613 Mon Sep 17 00:00:00 2001 From: Manuel Lopez Date: Tue, 2 May 2023 02:56:09 +0000 Subject: [PATCH 05/15] add inputs to ensure poetry --- actions/ensure-poetry/action.yaml | 11 ++++++++++- actions/ensure-poetry/ensure-poetry.sh | 14 ++++++++------ 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/actions/ensure-poetry/action.yaml b/actions/ensure-poetry/action.yaml index b4c35346..6d903d2e 100644 --- a/actions/ensure-poetry/action.yaml +++ b/actions/ensure-poetry/action.yaml @@ -5,6 +5,14 @@ inputs: description: poetry version to install default: latest required: false + venv-base-path: + description: basepath for the venv + default: /opt/venv + required: false + venv-name: + description: name of the venv + default: workspace + required: false runs: using: 'composite' steps: @@ -18,4 +26,5 @@ runs: - name: ensure poetry id: venv-cache shell: bash - run: ${GITHUB_ACTION_PATH}/ensure-poetry.sh ${{ inputs.poetry-version }} + run: | + ${GITHUB_ACTION_PATH}/ensure-poetry.sh ${{ inputs.poetry-version }} ${{ inputs.venv-base-path }} ${{ inputs.venv-base-path }} ${{ inputs.venv-name }} diff --git a/actions/ensure-poetry/ensure-poetry.sh b/actions/ensure-poetry/ensure-poetry.sh index be49e666..111f1645 100755 --- a/actions/ensure-poetry/ensure-poetry.sh +++ b/actions/ensure-poetry/ensure-poetry.sh @@ -1,11 +1,13 @@ #!/bin/bash poetryVersion="${1:-latest}" +venvBasePath="${2:-/opt/venv}" +venvName="${3:-workspace}" set -exuo pipefail -python3 -m venv /opt/venv/workspace -. /opt/venv/workspace/bin/activate +python3 -m venv "$venvBasePath/$venvName" +. "$venvBasePath/$venvName/bin/activate" poetryPath=$(which poetry || echo '') if [ "$poetryPath" == '' ]; then @@ -17,9 +19,9 @@ if [ "$poetryPath" == '' ]; then fi { - echo "POETRY_HOME=/opt/venv/poetry" - echo "POETRY_CACHE_DIR=/opt/venv/.cache/pypoetry" - echo "VIRTUAL_ENV=/opt/venv/workspace" + echo "POETRY_HOME=$venvBasePath/poetry" + echo "POETRY_CACHE_DIR=$venvBasePath/.cache/pypoetry" + echo "VIRTUAL_ENV=$venvBasePath/$venvName" } >> "$GITHUB_ENV" -echo "/opt/venv/workspace/bin" >> $GITHUB_PATH +echo "$venvBasePath/$venvName/bin" >> $GITHUB_PATH From b5238f5fb572b91b0a1ccd80ff7bfd59683bbfa5 Mon Sep 17 00:00:00 2001 From: Manuel Lopez Date: Tue, 2 May 2023 03:04:19 +0000 Subject: [PATCH 06/15] testing action --- .github/workflows/builder.yaml | 71 +++++++++++----------------------- 1 file changed, 23 insertions(+), 48 deletions(-) diff --git a/.github/workflows/builder.yaml b/.github/workflows/builder.yaml index 91f19170..b38d3bff 100644 --- a/.github/workflows/builder.yaml +++ b/.github/workflows/builder.yaml @@ -7,7 +7,6 @@ on: branches: [master] env: - VIRTUAL_ENV: /opt/venv/m PYTHONPATH: ./packages/python FORCE_COLOR: 1 MYPY_FORCE_COLOR: 1 @@ -16,28 +15,13 @@ env: jobs: setup: runs-on: ubuntu-22.04 - strategy: - matrix: - py-ver: [py310, py311] - container: - image: ghcr.io/jmlopez-rod/m-devcontainer-${{ matrix.py-ver }}:latest - credentials: - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} steps: - name: Checkout uses: actions/checkout@v3 - + - name: Ensure poetry + uses: jmlopez-rod/m/actions/ensure-poetry@actions-cache - name: Install - run: | - python3 -m venv /opt/venv/m - poetry install - - - name: Cache venv - uses: actions/cache@v3 - with: - path: /opt/venv/m - key: venv-${{ matrix.py-ver }}-${{ hashFiles('**/poetry.lock') }} + run: poetry install tests: needs: setup @@ -53,13 +37,10 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 - - - name: Cache venv - uses: actions/cache@v3 - with: - path: /opt/venv/m - key: venv-${{ matrix.py-ver }}-${{ hashFiles('**/poetry.lock') }} - + - name: Ensure poetry + uses: jmlopez-rod/m/actions/ensure-poetry@actions-cache + - name: Install + run: poetry install - name: run tests run: ./packages/python/tests/run.sh @@ -74,12 +55,10 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 - - - name: Cache venv - uses: actions/cache@v3 - with: - path: /opt/venv/m - key: venv-py311-${{ hashFiles('**/poetry.lock') }} + - name: Ensure poetry + uses: jmlopez-rod/m/actions/ensure-poetry@actions-cache + - name: Install + run: poetry install - name: lint src shell: bash @@ -102,12 +81,10 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 - - - name: Cache venv - uses: actions/cache@v3 - with: - path: /opt/venv/m - key: venv-py311-${{ hashFiles('**/poetry.lock') }} + - name: Ensure poetry + uses: jmlopez-rod/m/actions/ensure-poetry@actions-cache + - name: Install + run: poetry install - name: src run: | @@ -129,11 +106,10 @@ jobs: - name: Checkout uses: actions/checkout@v3 - - name: Cache venv - uses: actions/cache@v3 - with: - path: /opt/venv/m - key: venv-py311-${{ hashFiles('**/poetry.lock') }} + - name: Ensure poetry + uses: jmlopez-rod/m/actions/ensure-poetry@actions-cache + - name: Install + run: poetry install - name: src shell: bash @@ -180,11 +156,10 @@ jobs: - name: Checkout uses: actions/checkout@v3 - - name: Cache venv - uses: actions/cache@v3 - with: - path: /opt/venv/m - key: venv-py311-${{ hashFiles('**/poetry.lock') }} + - name: Ensure poetry + uses: jmlopez-rod/m/actions/ensure-poetry@actions-cache + - name: Install + run: poetry install - name: Build id: build From 7f1e588a8ce878743272c07eac9fc39b4f8f55c8 Mon Sep 17 00:00:00 2001 From: Manuel Lopez Date: Tue, 2 May 2023 03:23:19 +0000 Subject: [PATCH 07/15] specify python version --- .github/workflows/builder.yaml | 5 +++++ actions/ensure-poetry/action.yaml | 11 ++++++++--- actions/ensure-poetry/ensure-poetry.sh | 3 ++- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/.github/workflows/builder.yaml b/.github/workflows/builder.yaml index b38d3bff..4ce98940 100644 --- a/.github/workflows/builder.yaml +++ b/.github/workflows/builder.yaml @@ -15,11 +15,16 @@ env: jobs: setup: runs-on: ubuntu-22.04 + strategy: + matrix: + py-ver: ['3.10', '3.11'] steps: - name: Checkout uses: actions/checkout@v3 - name: Ensure poetry uses: jmlopez-rod/m/actions/ensure-poetry@actions-cache + with: + python-version: ${{ matrix.py-ver }} - name: Install run: poetry install diff --git a/actions/ensure-poetry/action.yaml b/actions/ensure-poetry/action.yaml index 6d903d2e..50a9182c 100644 --- a/actions/ensure-poetry/action.yaml +++ b/actions/ensure-poetry/action.yaml @@ -1,6 +1,10 @@ name: 'm ensure-poetry' description: 'ensure that poetry is installed and cache the venv' inputs: + python-version: + description: specify major and minor version of python + default: 3.11 + required: false poetry-version: description: poetry version to install default: latest @@ -20,11 +24,12 @@ runs: uses: actions/cache@v3 with: path: /opt/venv - key: ${{ runner.os }}-venv-${{ hashFiles('**/poetry.lock') }} - restore-keys: ${{ runner.os }}-venv- + # prettier-ignore + key: ${{ runner.os }}-${{ inputs.python-version }}-venv-${{ hashFiles('**/poetry.lock') }} + restore-keys: ${{ runner.os }}-${{ inputs.python-version }}-venv- - name: ensure poetry id: venv-cache shell: bash run: | - ${GITHUB_ACTION_PATH}/ensure-poetry.sh ${{ inputs.poetry-version }} ${{ inputs.venv-base-path }} ${{ inputs.venv-base-path }} ${{ inputs.venv-name }} + ${GITHUB_ACTION_PATH}/ensure-poetry.sh ${{ inputs.poetry-version }} ${{ inputs.venv-base-path }} ${{ inputs.venv-base-path }} ${{ inputs.venv-name }} ${{ inputs.python-version }} diff --git a/actions/ensure-poetry/ensure-poetry.sh b/actions/ensure-poetry/ensure-poetry.sh index 111f1645..bc5e9495 100755 --- a/actions/ensure-poetry/ensure-poetry.sh +++ b/actions/ensure-poetry/ensure-poetry.sh @@ -3,10 +3,11 @@ poetryVersion="${1:-latest}" venvBasePath="${2:-/opt/venv}" venvName="${3:-workspace}" +pythonVer="${4:-}" set -exuo pipefail -python3 -m venv "$venvBasePath/$venvName" +"python${pythonVer}" -m venv "$venvBasePath/$venvName" . "$venvBasePath/$venvName/bin/activate" poetryPath=$(which poetry || echo '') From 185517d988bd1087fca11773ea87b90397d474d5 Mon Sep 17 00:00:00 2001 From: Manuel Lopez Date: Tue, 2 May 2023 03:25:10 +0000 Subject: [PATCH 08/15] remove repeated argument --- actions/ensure-poetry/action.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/actions/ensure-poetry/action.yaml b/actions/ensure-poetry/action.yaml index 50a9182c..dc8b5e7d 100644 --- a/actions/ensure-poetry/action.yaml +++ b/actions/ensure-poetry/action.yaml @@ -32,4 +32,4 @@ runs: id: venv-cache shell: bash run: | - ${GITHUB_ACTION_PATH}/ensure-poetry.sh ${{ inputs.poetry-version }} ${{ inputs.venv-base-path }} ${{ inputs.venv-base-path }} ${{ inputs.venv-name }} ${{ inputs.python-version }} + ${GITHUB_ACTION_PATH}/ensure-poetry.sh ${{ inputs.poetry-version }} ${{ inputs.venv-base-path }} ${{ inputs.venv-name }} ${{ inputs.python-version }} From fe1b11fc445a3af60df3459d19e9fe4dbded748a Mon Sep 17 00:00:00 2001 From: Manuel Lopez Date: Tue, 2 May 2023 03:44:31 +0000 Subject: [PATCH 09/15] simplify with action --- .github/workflows/builder.yaml | 67 ++++++++++++++------------ actions/ensure-poetry/action.yaml | 14 +++--- actions/ensure-poetry/ensure-poetry.sh | 3 +- 3 files changed, 45 insertions(+), 39 deletions(-) diff --git a/.github/workflows/builder.yaml b/.github/workflows/builder.yaml index 4ce98940..7f09af39 100644 --- a/.github/workflows/builder.yaml +++ b/.github/workflows/builder.yaml @@ -7,6 +7,7 @@ on: branches: [master] env: + VIRTUAL_ENV: /opt/venv/m PYTHONPATH: ./packages/python FORCE_COLOR: 1 MYPY_FORCE_COLOR: 1 @@ -17,16 +18,18 @@ jobs: runs-on: ubuntu-22.04 strategy: matrix: - py-ver: ['3.10', '3.11'] + py-ver: [py310, py311] + container: + image: ghcr.io/jmlopez-rod/m-devcontainer-${{ matrix.py-ver }}:latest + credentials: + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Ensure poetry - uses: jmlopez-rod/m/actions/ensure-poetry@actions-cache + - uses: actions/checkout@v3 + - uses: jmlopez-rod/m/actions/ensure-poetry@actions-cache with: - python-version: ${{ matrix.py-ver }} - - name: Install - run: poetry install + cache-key: ${{ matrix.py-ver }} + - run: poetry install tests: needs: setup @@ -40,12 +43,10 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Ensure poetry - uses: jmlopez-rod/m/actions/ensure-poetry@actions-cache - - name: Install - run: poetry install + - uses: actions/checkout@v3 + - uses: jmlopez-rod/m/actions/ensure-poetry@actions-cache + with: + cache-key: ${{ matrix.py-ver }} - name: run tests run: ./packages/python/tests/run.sh @@ -60,10 +61,12 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 - - name: Ensure poetry - uses: jmlopez-rod/m/actions/ensure-poetry@actions-cache - - name: Install - run: poetry install + + - name: Cache venv + uses: actions/cache@v3 + with: + path: /opt/venv/m + key: venv-py311-${{ hashFiles('**/poetry.lock') }} - name: lint src shell: bash @@ -86,10 +89,12 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 - - name: Ensure poetry - uses: jmlopez-rod/m/actions/ensure-poetry@actions-cache - - name: Install - run: poetry install + + - name: Cache venv + uses: actions/cache@v3 + with: + path: /opt/venv/m + key: venv-py311-${{ hashFiles('**/poetry.lock') }} - name: src run: | @@ -111,10 +116,11 @@ jobs: - name: Checkout uses: actions/checkout@v3 - - name: Ensure poetry - uses: jmlopez-rod/m/actions/ensure-poetry@actions-cache - - name: Install - run: poetry install + - name: Cache venv + uses: actions/cache@v3 + with: + path: /opt/venv/m + key: venv-py311-${{ hashFiles('**/poetry.lock') }} - name: src shell: bash @@ -161,10 +167,11 @@ jobs: - name: Checkout uses: actions/checkout@v3 - - name: Ensure poetry - uses: jmlopez-rod/m/actions/ensure-poetry@actions-cache - - name: Install - run: poetry install + - name: Cache venv + uses: actions/cache@v3 + with: + path: /opt/venv/m + key: venv-py311-${{ hashFiles('**/poetry.lock') }} - name: Build id: build diff --git a/actions/ensure-poetry/action.yaml b/actions/ensure-poetry/action.yaml index dc8b5e7d..67df8849 100644 --- a/actions/ensure-poetry/action.yaml +++ b/actions/ensure-poetry/action.yaml @@ -1,10 +1,6 @@ name: 'm ensure-poetry' description: 'ensure that poetry is installed and cache the venv' inputs: - python-version: - description: specify major and minor version of python - default: 3.11 - required: false poetry-version: description: poetry version to install default: latest @@ -17,6 +13,10 @@ inputs: description: name of the venv default: workspace required: false + cache-key: + description: key to use for the cache + default: '' + required: false runs: using: 'composite' steps: @@ -25,11 +25,11 @@ runs: with: path: /opt/venv # prettier-ignore - key: ${{ runner.os }}-${{ inputs.python-version }}-venv-${{ hashFiles('**/poetry.lock') }} - restore-keys: ${{ runner.os }}-${{ inputs.python-version }}-venv- + key: ${{ runner.os }}-venv-${{ inputs.cache-key }}-${{ hashFiles('**/poetry.lock') }} + restore-keys: ${{ runner.os }}-venv-${{ inputs.cache-key }}- - name: ensure poetry id: venv-cache shell: bash run: | - ${GITHUB_ACTION_PATH}/ensure-poetry.sh ${{ inputs.poetry-version }} ${{ inputs.venv-base-path }} ${{ inputs.venv-name }} ${{ inputs.python-version }} + ${GITHUB_ACTION_PATH}/ensure-poetry.sh ${{ inputs.poetry-version }} ${{ inputs.venv-base-path }} ${{ inputs.venv-name }} diff --git a/actions/ensure-poetry/ensure-poetry.sh b/actions/ensure-poetry/ensure-poetry.sh index bc5e9495..847a4d82 100755 --- a/actions/ensure-poetry/ensure-poetry.sh +++ b/actions/ensure-poetry/ensure-poetry.sh @@ -3,11 +3,10 @@ poetryVersion="${1:-latest}" venvBasePath="${2:-/opt/venv}" venvName="${3:-workspace}" -pythonVer="${4:-}" set -exuo pipefail -"python${pythonVer}" -m venv "$venvBasePath/$venvName" +python -m venv "$venvBasePath/$venvName" . "$venvBasePath/$venvName/bin/activate" poetryPath=$(which poetry || echo '') From b114f990876cef748ba8e5bb8d77ffd23492df9c Mon Sep 17 00:00:00 2001 From: Manuel Lopez Date: Tue, 2 May 2023 03:52:50 +0000 Subject: [PATCH 10/15] update build --- .github/workflows/builder.yaml | 91 ++++++++-------------------------- 1 file changed, 22 insertions(+), 69 deletions(-) diff --git a/.github/workflows/builder.yaml b/.github/workflows/builder.yaml index 7f09af39..73404116 100644 --- a/.github/workflows/builder.yaml +++ b/.github/workflows/builder.yaml @@ -59,20 +59,14 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Cache venv - uses: actions/cache@v3 + - uses: actions/checkout@v3 + - uses: jmlopez-rod/m/actions/ensure-poetry@actions-cache with: - path: /opt/venv/m - key: venv-py311-${{ hashFiles('**/poetry.lock') }} - + cache-key: py311 - name: lint src shell: bash run: | m ci celt -t flake8 -c @allowed_errors.json < <(flake8 packages/python/m) - - name: lint tests shell: bash run: | @@ -87,22 +81,12 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Cache venv - uses: actions/cache@v3 + - uses: actions/checkout@v3 + - uses: jmlopez-rod/m/actions/ensure-poetry@actions-cache with: - path: /opt/venv/m - key: venv-py311-${{ hashFiles('**/poetry.lock') }} - - - name: src - run: | - mypy ./packages/python/m - - - name: tests - run: | - mypy ./packages/python/tests + cache-key: py311 + - run: mypy ./packages/python/m + - run: mypy ./packages/python/tests pylint: needs: setup @@ -113,20 +97,14 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Cache venv - uses: actions/cache@v3 + - uses: actions/checkout@v3 + - uses: jmlopez-rod/m/actions/ensure-poetry@actions-cache with: - path: /opt/venv/m - key: venv-py311-${{ hashFiles('**/poetry.lock') }} - + cache-key: py311 - name: src shell: bash run: | m ci celt -t pylint -m 10 -c @allowed_errors.json < <(pylint ./packages/python/m --rcfile=.pylintrc -f json) - - name: tests shell: bash run: | @@ -134,23 +112,11 @@ jobs: prettier: runs-on: ubuntu-22.04 - container: - image: ghcr.io/jmlopez-rod/m-devcontainer-py311:latest - credentials: - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: pnpm install - run: | - pnpm install - - - name: prettier - shell: bash - run: | - pnpm exec prettier -c . + - uses: actions/checkout@v3 + - uses: jmlopez-rod/m/actions/ensure-pnpm@actions-cache + - run: pnpm install + - run: pnpm exec prettier -c . build: needs: setup @@ -164,20 +130,13 @@ jobs: m-is-release: ${{ steps.build.outputs.m-is-release }} m-tag: ${{ steps.build.outputs.m-tag }} steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Cache venv - uses: actions/cache@v3 + - uses: actions/checkout@v3 + - uses: jmlopez-rod/m/actions/ensure-poetry@actions-cache with: - path: /opt/venv/m - key: venv-py311-${{ hashFiles('**/poetry.lock') }} - + cache-key: py311 - name: Build id: build - run: | - ./m/scripts/build.sh - + run: ./m/scripts/build.sh - name: Save build uses: actions/cache/save@v3 with: @@ -198,21 +157,15 @@ jobs: TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} M_TAG: ${{ needs.build.outputs.m-tag }} steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Cache venv - uses: actions/cache@v3 + - uses: actions/checkout@v3 + - uses: jmlopez-rod/m/actions/ensure-poetry@actions-cache with: - path: /opt/venv/m - key: venv-py311-${{ hashFiles('**/poetry.lock') }} - + cache-key: py311 - name: Restore build uses: actions/cache/restore@v3 with: path: ./.stage-pypi key: build-${{ github.sha }} - - name: Release run: | ./m/scripts/publish.sh From c313adf7b8d1007e1b42f56baa205534d8e22d5a Mon Sep 17 00:00:00 2001 From: Manuel Lopez Date: Tue, 2 May 2023 03:54:11 +0000 Subject: [PATCH 11/15] lock prettier version --- .github/workflows/builder.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/builder.yaml b/.github/workflows/builder.yaml index 73404116..71bc0054 100644 --- a/.github/workflows/builder.yaml +++ b/.github/workflows/builder.yaml @@ -115,6 +115,8 @@ jobs: steps: - uses: actions/checkout@v3 - uses: jmlopez-rod/m/actions/ensure-pnpm@actions-cache + with: + pnpm-version: 7.15.0 - run: pnpm install - run: pnpm exec prettier -c . From e0f3efc8f09b3a319407f673141243b5055a7fa1 Mon Sep 17 00:00:00 2001 From: Manuel Lopez Date: Fri, 5 May 2023 20:06:05 +0000 Subject: [PATCH 12/15] skip downloading container for setup --- .github/workflows/builder.yaml | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/.github/workflows/builder.yaml b/.github/workflows/builder.yaml index 71bc0054..61d95190 100644 --- a/.github/workflows/builder.yaml +++ b/.github/workflows/builder.yaml @@ -18,17 +18,15 @@ jobs: runs-on: ubuntu-22.04 strategy: matrix: - py-ver: [py310, py311] - container: - image: ghcr.io/jmlopez-rod/m-devcontainer-${{ matrix.py-ver }}:latest - credentials: - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} + py-ver: ['3.10.11', '3.11.3'] steps: - uses: actions/checkout@v3 + - uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.py-ver }} - uses: jmlopez-rod/m/actions/ensure-poetry@actions-cache with: - cache-key: ${{ matrix.py-ver }} + cache-key: poetry-py-${{ matrix.py-ver }} - run: poetry install tests: From b3b3f7ceb3c55537808a37317be9ef9d2f343089 Mon Sep 17 00:00:00 2001 From: Manuel Lopez Date: Fri, 5 May 2023 20:09:33 +0000 Subject: [PATCH 13/15] checking cache --- .github/workflows/builder.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/builder.yaml b/.github/workflows/builder.yaml index 61d95190..6437e559 100644 --- a/.github/workflows/builder.yaml +++ b/.github/workflows/builder.yaml @@ -21,6 +21,7 @@ jobs: py-ver: ['3.10.11', '3.11.3'] steps: - uses: actions/checkout@v3 + - uses: actions/setup-python@v4 with: python-version: ${{ matrix.py-ver }} From 04b4e651babf064925787a04fb31fe3ccbbfbd1d Mon Sep 17 00:00:00 2001 From: Manuel Lopez Date: Fri, 5 May 2023 20:22:19 +0000 Subject: [PATCH 14/15] reusing cache --- .github/workflows/builder.yaml | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/.github/workflows/builder.yaml b/.github/workflows/builder.yaml index 6437e559..86219806 100644 --- a/.github/workflows/builder.yaml +++ b/.github/workflows/builder.yaml @@ -21,13 +21,12 @@ jobs: py-ver: ['3.10.11', '3.11.3'] steps: - uses: actions/checkout@v3 - - uses: actions/setup-python@v4 with: python-version: ${{ matrix.py-ver }} - uses: jmlopez-rod/m/actions/ensure-poetry@actions-cache with: - cache-key: poetry-py-${{ matrix.py-ver }} + cache-key: ${{ matrix.py-ver }} - run: poetry install tests: @@ -35,14 +34,18 @@ jobs: runs-on: ubuntu-22.04 strategy: matrix: - py-ver: [py310, py311] - container: - image: ghcr.io/jmlopez-rod/m-devcontainer-${{ matrix.py-ver }}:latest - credentials: - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} + py-ver: ['3.10.11', '3.11.3'] + # py-ver: [py310, py311] + # container: + # image: ghcr.io/jmlopez-rod/m-devcontainer-${{ matrix.py-ver }}:latest + # credentials: + # username: ${{ github.actor }} + # password: ${{ secrets.GITHUB_TOKEN }} steps: - uses: actions/checkout@v3 + - uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.py-ver }} - uses: jmlopez-rod/m/actions/ensure-poetry@actions-cache with: cache-key: ${{ matrix.py-ver }} @@ -61,7 +64,7 @@ jobs: - uses: actions/checkout@v3 - uses: jmlopez-rod/m/actions/ensure-poetry@actions-cache with: - cache-key: py311 + cache-key: '3.11.3' - name: lint src shell: bash run: | @@ -83,7 +86,7 @@ jobs: - uses: actions/checkout@v3 - uses: jmlopez-rod/m/actions/ensure-poetry@actions-cache with: - cache-key: py311 + cache-key: '3.11.3' - run: mypy ./packages/python/m - run: mypy ./packages/python/tests @@ -99,7 +102,7 @@ jobs: - uses: actions/checkout@v3 - uses: jmlopez-rod/m/actions/ensure-poetry@actions-cache with: - cache-key: py311 + cache-key: '3.11.3' - name: src shell: bash run: | @@ -134,7 +137,7 @@ jobs: - uses: actions/checkout@v3 - uses: jmlopez-rod/m/actions/ensure-poetry@actions-cache with: - cache-key: py311 + cache-key: '3.11.3' - name: Build id: build run: ./m/scripts/build.sh @@ -161,7 +164,7 @@ jobs: - uses: actions/checkout@v3 - uses: jmlopez-rod/m/actions/ensure-poetry@actions-cache with: - cache-key: py311 + cache-key: '3.11.3' - name: Restore build uses: actions/cache/restore@v3 with: From 9e6a2197f4e49ba530b1fe18e5585c410c23bfd7 Mon Sep 17 00:00:00 2001 From: Manuel Lopez Date: Fri, 5 May 2023 20:30:23 +0000 Subject: [PATCH 15/15] print out the environment --- .github/workflows/builder.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/builder.yaml b/.github/workflows/builder.yaml index 86219806..4fdea292 100644 --- a/.github/workflows/builder.yaml +++ b/.github/workflows/builder.yaml @@ -65,6 +65,8 @@ jobs: - uses: jmlopez-rod/m/actions/ensure-poetry@actions-cache with: cache-key: '3.11.3' + - name: env + run: env - name: lint src shell: bash run: |