From ee46b46234bed5372f4e96e34396ea04b893e609 Mon Sep 17 00:00:00 2001 From: Peter W <34256109+pww217@users.noreply.github.com> Date: Fri, 20 May 2022 13:45:49 -0500 Subject: [PATCH] Add testing to CI flow (#418) * new testing ci flow * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * install conda * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * test conda * pre-commit fix * remove if * makefile fix * fix pytest install * argument for test * restructure * fix sync * full path filter * use setup-condav2 * syntax * test path * add binary argument * remove which * Update Makefile * remove arguments * trigger CI Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .github/workflows/build-alpha.yml | 32 +++++++++++++++++++++++------- .github/workflows/build-latest.yml | 28 ++++++++++++++++++++------ .github/workflows/docs-latest.yml | 2 ++ .github/workflows/docs-release.yml | 2 ++ .github/workflows/docs-review.yml | 2 ++ pyscriptjs/Makefile | 5 +++-- 6 files changed, 56 insertions(+), 15 deletions(-) diff --git a/.github/workflows/build-alpha.yml b/.github/workflows/build-alpha.yml index 5fe5f510..93973d2b 100644 --- a/.github/workflows/build-alpha.yml +++ b/.github/workflows/build-alpha.yml @@ -7,47 +7,65 @@ on: paths: - pyscriptjs/** +env: + MINICONDA_PYTHON_VERSION: py38 + MINICONDA_VERSION: 4.11.0 + +defaults: + run: + working-directory: pyscriptjs + jobs: build: runs-on: ubuntu-latest permissions: contents: read id-token: write - defaults: - run: - working-directory: pyscriptjs - steps: + - name: Checkout uses: actions/checkout@v3 + - name: Install node uses: actions/setup-node@v3 with: node-version: 18.x + - name: Cache node modules uses: actions/cache@v3 env: cache-name: cache-node-modules with: - # npm cache files are stored in `~/.npm` on Linux/macOS + # npm cache files are stored in `~/.npm` on Linux/macOS path: ~/.npm key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} restore-keys: | ${{ runner.os }}-build-${{ env.cache-name }}- ${{ runner.os }}-build- ${{ runner.os }}- + + - name: setup Miniconda + uses: conda-incubator/setup-miniconda@v2 + - name: Install dependencies run: | npm install + make setup + + - name: Test pyscript + run: make test + - name: Build pyscript - run: | - npm run build + run: make build # Deploy to S3 - name: Configure AWS credentials + if: github.ref == 'refs/heads/main' # Only deploy on merge into main uses: aws-actions/configure-aws-credentials@v1.6.1 with: aws-region: ${{secrets.AWS_REGION}} role-to-assume: ${{ secrets.AWS_OIDC_RUNNER_ROLE }} + - name: Sync to S3 + if: github.ref == 'refs/heads/main' run: aws s3 sync --quiet ./examples/build/ s3://pyscript.net/alpha/ diff --git a/.github/workflows/build-latest.yml b/.github/workflows/build-latest.yml index 6b546974..1ffe8e30 100644 --- a/.github/workflows/build-latest.yml +++ b/.github/workflows/build-latest.yml @@ -15,23 +15,30 @@ on: - pyscriptjs/** - .github/workflows/build-latest.yml # Test that workflow works when changed +env: + MINICONDA_PYTHON_VERSION: py38 + MINICONDA_VERSION: 4.11.0 + +defaults: + run: + working-directory: pyscriptjs + jobs: build: runs-on: ubuntu-latest permissions: contents: read id-token: write - defaults: - run: - working-directory: pyscriptjs - steps: + - name: Checkout uses: actions/checkout@v3 + - name: Install node uses: actions/setup-node@v3 with: node-version: 18.x + - name: Cache node modules uses: actions/cache@v3 env: @@ -44,12 +51,20 @@ jobs: ${{ runner.os }}-build-${{ env.cache-name }}- ${{ runner.os }}-build- ${{ runner.os }}- + + - name: setup Miniconda + uses: conda-incubator/setup-miniconda@v2 + - name: Install dependencies run: | npm install + make setup + + - name: Test pyscript + run: make test + - name: Build pyscript - run: | - npm run build + run: make build # Deploy to S3 - name: Configure AWS credentials @@ -58,6 +73,7 @@ jobs: with: aws-region: ${{secrets.AWS_REGION}} role-to-assume: ${{ secrets.AWS_OIDC_RUNNER_ROLE }} + - name: Sync to S3 if: github.ref == 'refs/heads/main' run: aws s3 sync --quiet ./examples/build/ s3://pyscript.net/unstable diff --git a/.github/workflows/docs-latest.yml b/.github/workflows/docs-latest.yml index 277ccd49..1a05385e 100644 --- a/.github/workflows/docs-latest.yml +++ b/.github/workflows/docs-latest.yml @@ -4,6 +4,8 @@ on: push: branches: - main + paths: + - docs/** jobs: build: diff --git a/.github/workflows/docs-release.yml b/.github/workflows/docs-release.yml index 4cc50c86..a007e9bc 100644 --- a/.github/workflows/docs-release.yml +++ b/.github/workflows/docs-release.yml @@ -4,6 +4,8 @@ on: # Any time a tag or branch is created # https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#create create: + paths: + - docs/** jobs: build: diff --git a/.github/workflows/docs-review.yml b/.github/workflows/docs-review.yml index dfbac887..358efd24 100644 --- a/.github/workflows/docs-review.yml +++ b/.github/workflows/docs-review.yml @@ -4,6 +4,8 @@ on: pull_request: branches: - '*' + paths: + - docs/** concurrency: # Concurrency group that uses the workflow name and PR number if available diff --git a/pyscriptjs/Makefile b/pyscriptjs/Makefile index 3a1d386d..d08c84f8 100644 --- a/pyscriptjs/Makefile +++ b/pyscriptjs/Makefile @@ -6,14 +6,15 @@ src_dir ?= $(base_dir)/src examples ?= $(base_dir)/examples app_dir ?= $(shell git rev-parse --show-prefix) +CONDA_EXE := conda CONDA_ENV ?= ./env env := $(CONDA_ENV) -conda_run := conda run -p $(env) +conda_run := $(CONDA_EXE) run -p $(env) setup: - @if [ -z "$${CONDA_SHLVL:+x}" ]; then echo "Conda is not installed." && exit 1; fi $(CONDA_EXE) env $(shell [ -d $(env) ] && echo update || echo create) -p $(env) --file environment.yml $(conda_run) playwright install + $(CONDA_EXE) install -c anaconda pytest clean: find . -name \*.py[cod] -delete