diff --git a/taxonium_component/.github/workflows/docker-publish-backend.yml b/taxonium_component/.github/workflows/docker-publish-backend.yml new file mode 100644 index 00000000..b989c235 --- /dev/null +++ b/taxonium_component/.github/workflows/docker-publish-backend.yml @@ -0,0 +1,72 @@ +name: Docker publish backend + +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +on: + repository_dispatch: + workflow_dispatch: + schedule: + - cron: "37 18 * * *" + push: + branches: [master, staging] + # Publish semver tags as releases. + tags: ["v*.*.*"] + pull_request: + branches: [master, staging] + +env: + # Use docker.io for Docker Hub if empty + REGISTRY: docker.io + # github.repository as / + IMAGE_NAME: theosanderson/taxonium_backend + +jobs: + build: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + # This is used to complete the identity challenge + # with sigstore/fulcio when running outside of PRs. + id-token: write + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + # Workaround: https://github.com/docker/build-push-action/issues/461 + - name: Setup Docker buildx + uses: docker/setup-buildx-action@79abd3f86f79a9d68a23c75a09a9a85889262adf + + # Login against a Docker registry except on PR + # https://github.com/docker/login-action + - name: Log into registry ${{ env.REGISTRY }} + if: github.event_name != 'pull_request' + uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c + with: + registry: ${{ env.REGISTRY }} + username: theosanderson + password: ${{ secrets.DOCKER_TOKEN }} + + # Extract metadata (tags, labels) for Docker + # https://github.com/docker/metadata-action + - name: Extract Docker metadata + id: meta + uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + # Build and push Docker image with Buildx (don't push on PR) + # https://github.com/docker/build-push-action + - name: Build and push Docker image + id: build-and-push + uses: docker/build-push-action@ac9327eae2b366085ac7f6a2d02df8aa8ead720a + with: + context: . + file: ./Dockerfile.backend + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/taxonium_component/.github/workflows/docker-publish-frontend.yml b/taxonium_component/.github/workflows/docker-publish-frontend.yml new file mode 100644 index 00000000..d68b2fc0 --- /dev/null +++ b/taxonium_component/.github/workflows/docker-publish-frontend.yml @@ -0,0 +1,72 @@ +name: Docker publish frontend + +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +on: + repository_dispatch: + workflow_dispatch: + schedule: + - cron: "37 18 * * *" + push: + branches: [master, staging] + # Publish semver tags as releases. + tags: ["v*.*.*"] + pull_request: + branches: [master, staging] + +env: + # Use docker.io for Docker Hub if empty + REGISTRY: docker.io + # github.repository as / + IMAGE_NAME: theosanderson/taxonium_frontend + +jobs: + build: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + # This is used to complete the identity challenge + # with sigstore/fulcio when running outside of PRs. + id-token: write + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + # Workaround: https://github.com/docker/build-push-action/issues/461 + - name: Setup Docker buildx + uses: docker/setup-buildx-action@79abd3f86f79a9d68a23c75a09a9a85889262adf + + # Login against a Docker registry except on PR + # https://github.com/docker/login-action + - name: Log into registry ${{ env.REGISTRY }} + if: github.event_name != 'pull_request' + uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c + with: + registry: ${{ env.REGISTRY }} + username: theosanderson + password: ${{ secrets.DOCKER_TOKEN }} + + # Extract metadata (tags, labels) for Docker + # https://github.com/docker/metadata-action + - name: Extract Docker metadata + id: meta + uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + # Build and push Docker image with Buildx (don't push on PR) + # https://github.com/docker/build-push-action + - name: Build and push Docker image + id: build-and-push + uses: docker/build-push-action@ac9327eae2b366085ac7f6a2d02df8aa8ead720a + with: + context: . + file: ./Dockerfile.frontend + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/taxonium_component/.github/workflows/docker-publish-proxy.yml b/taxonium_component/.github/workflows/docker-publish-proxy.yml new file mode 100644 index 00000000..e60137f5 --- /dev/null +++ b/taxonium_component/.github/workflows/docker-publish-proxy.yml @@ -0,0 +1,72 @@ +name: Docker publish proxy + +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +on: + repository_dispatch: + workflow_dispatch: + schedule: + - cron: "37 18 * * *" + push: + branches: [master, staging] + # Publish semver tags as releases. + tags: ["v*.*.*"] + pull_request: + branches: [master, staging] + +env: + # Use docker.io for Docker Hub if empty + REGISTRY: docker.io + # github.repository as / + IMAGE_NAME: theosanderson/taxonium_proxy + +jobs: + build: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + # This is used to complete the identity challenge + # with sigstore/fulcio when running outside of PRs. + id-token: write + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + # Workaround: https://github.com/docker/build-push-action/issues/461 + - name: Setup Docker buildx + uses: docker/setup-buildx-action@79abd3f86f79a9d68a23c75a09a9a85889262adf + + # Login against a Docker registry except on PR + # https://github.com/docker/login-action + - name: Log into registry ${{ env.REGISTRY }} + if: github.event_name != 'pull_request' + uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c + with: + registry: ${{ env.REGISTRY }} + username: theosanderson + password: ${{ secrets.DOCKER_TOKEN }} + + # Extract metadata (tags, labels) for Docker + # https://github.com/docker/metadata-action + - name: Extract Docker metadata + id: meta + uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + # Build and push Docker image with Buildx (don't push on PR) + # https://github.com/docker/build-push-action + - name: Build and push Docker image + id: build-and-push + uses: docker/build-push-action@ac9327eae2b366085ac7f6a2d02df8aa8ead720a + with: + context: . + file: ./Dockerfile.proxy + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/taxonium_component/.github/workflows/electron-release.yml b/taxonium_component/.github/workflows/electron-release.yml new file mode 100644 index 00000000..12fedd9f --- /dev/null +++ b/taxonium_component/.github/workflows/electron-release.yml @@ -0,0 +1,190 @@ +name: Electron build/release + +on: + workflow_dispatch: + release: + types: + - created + +jobs: + update-version: + runs-on: ubuntu-latest + + steps: + - name: Check out Git repository + uses: actions/checkout@v1 + + - name: Install Node.js, NPM and Yarn + uses: actions/setup-node@v1 + with: + node-version: 16 + + - name: Update package.json with GitHub tag + run: | + version=$(echo ${GITHUB_REF#refs/*/} | sed 's/^v//') + jq --arg version $version '.version = $version' taxonium_electron/package.json > temp.json + mv temp.json taxonium_electron/package.json + + - name: Upload package.json as artifact + uses: actions/upload-artifact@v3 + with: + name: package + path: taxonium_electron/package.json + + build-mac: + needs: update-version + runs-on: macos-latest + + steps: + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: "3.9" # or another compatible version + + - name: Check out Git repository + uses: actions/checkout@v1 + - name: Download updated package.json + uses: actions/download-artifact@v3 + with: + name: package + path: taxonium_electron/ + + - name: Install Node.js, NPM and Yarn + uses: actions/setup-node@v1 + with: + node-version: 16 + + - name: Build Electron app with electron-builder + run: | + cd taxonium_electron + source download.sh + yarn install + yarn add macos-alias + yarn make --arch=arm64 + yarn make --arch=x64 + env: + GH_TOKEN: ${{ secrets.GH_TOKEN }} + + - name: List output + run: | + cd taxonium_electron + cd out/make/ + find . + + - name: Store artifact + uses: actions/upload-artifact@v3 + with: + name: Build + path: taxonium_electron/out/make/Taxonium-*-arm64.dmg + + - name: Store artifact 2 + uses: actions/upload-artifact@v3 + with: + name: Build + path: taxonium_electron/out/make/Taxonium-*-x64.dmg + + - uses: shogo82148/actions-upload-release-asset@v1 + with: + upload_url: ${{ github.event.release.upload_url }} + asset_path: taxonium_electron/out/make/Taxonium-*-arm64.dmg + - uses: shogo82148/actions-upload-release-asset@v1 + with: + upload_url: ${{ github.event.release.upload_url }} + asset_path: taxonium_electron/out/make/Taxonium-*-x64.dmg + build-win: + needs: update-version + runs-on: windows-latest + + steps: + - name: Check out Git repository + uses: actions/checkout@v1 + - name: Download updated package.json + uses: actions/download-artifact@v3 + with: + name: package + path: taxonium_electron/ + + - name: Install Node.js, NPM and Yarn + uses: actions/setup-node@v1 + with: + node-version: 16 + + - name: Build Electron app with electron-builder + run: | + cd taxonium_electron + mkdir binaries + choco install wget --no-progress + wget https://cov2tree.nyc3.cdn.digitaloceanspaces.com/node_binaries/node18.exe -O binaries/node18.exe + yarn install + yarn make --win --arch=x64 + + - name: List output + run: | + cd taxonium_electron + cd out/make/squirrel.windows/x64 + dir + env: + GH_TOKEN: ${{ secrets.GH_TOKEN }} + + - name: Store artifact + uses: actions/upload-artifact@v3 + with: + name: Build + path: "taxonium_electron/out/make/squirrel.windows/x64/Taxonium-* Setup.exe" + + - uses: shogo82148/actions-upload-release-asset@v1 + with: + upload_url: ${{ github.event.release.upload_url }} + asset_path: "taxonium_electron/out/make/squirrel.windows/x64/Taxonium-* Setup.exe" + + build-linux: + needs: update-version + runs-on: ubuntu-latest + + steps: + - name: Check out Git repository + uses: actions/checkout@v1 + - name: Download updated package.json + uses: actions/download-artifact@v3 + with: + name: package + path: taxonium_electron/ + - name: Install Node.js, NPM and Yarn + uses: actions/setup-node@v1 + with: + node-version: 16 + + - name: Build Electron app with electron-builder + run: | + cd taxonium_electron + source download.sh + yarn install + yarn make --linux --arch=x64 + env: + GH_TOKEN: ${{ secrets.GH_TOKEN }} + + - name: List output + run: | + cd taxonium_electron + cd out/make + find . + + - name: Store artifact + uses: actions/upload-artifact@v3 + with: + name: Build + path: taxonium_electron/out/make/deb/x64/taxonium_*_amd64.deb + + - name: Store artifact + uses: actions/upload-artifact@v3 + with: + name: Build + path: taxonium_electron/out/make/rpm/x64/Taxonium-*-1.x86_64.rpm + - uses: shogo82148/actions-upload-release-asset@v1 + with: + upload_url: ${{ github.event.release.upload_url }} + asset_path: taxonium_electron/out/make/rpm/x64/Taxonium-*-1.x86_64.rpm + - uses: shogo82148/actions-upload-release-asset@v1 + with: + upload_url: ${{ github.event.release.upload_url }} + asset_path: taxonium_electron/out/make/deb/x64/taxonium_*_amd64.deb diff --git a/taxonium_component/.github/workflows/integration_test.yml b/taxonium_component/.github/workflows/integration_test.yml new file mode 100644 index 00000000..bcff0860 --- /dev/null +++ b/taxonium_component/.github/workflows/integration_test.yml @@ -0,0 +1,16 @@ +name: Integration Test + +on: + repository_dispatch: + workflow_dispatch: + push: + pull_request: + branches: [master] + schedule: + - cron: "0 0 * * *" +jobs: + python: + uses: ./.github/workflows/python-test.yml + playwright: + uses: ./.github/workflows/playwright.yml + needs: [python] diff --git a/taxonium_component/.github/workflows/playwright.yml b/taxonium_component/.github/workflows/playwright.yml new file mode 100644 index 00000000..1ef1dc45 --- /dev/null +++ b/taxonium_component/.github/workflows/playwright.yml @@ -0,0 +1,39 @@ +name: Playwright Tests +on: + repository_dispatch: + workflow_dispatch: + workflow_call: +jobs: + playwright: + timeout-minutes: 60 + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/download-artifact@v3 + with: + name: tfci-taxonium-config + path: ./data/ + - uses: actions/setup-node@v3 + with: + node-version: 18 + - name: Install Yarn + run: npm install -g yarn + - name: Install dependencies + run: NODE_OPTIONS='--max-old-space-size=4096' yarn install + working-directory: ./taxonium_website + - name: Install Playwright Browsers + run: yarn playwright install --with-deps + working-directory: ./taxonium_website + - name: Build + run: yarn build + working-directory: ./taxonium_website + - name: Run Playwright tests + run: pwd + yarn playwright test + working-directory: ./taxonium_website + - uses: actions/upload-artifact@v3 + if: always() + with: + name: playwright-report + path: ./taxonium_website/playwright-report/ + retention-days: 30 diff --git a/taxonium_component/.github/workflows/precommit-checker.yaml b/taxonium_component/.github/workflows/precommit-checker.yaml new file mode 100644 index 00000000..9f637ef8 --- /dev/null +++ b/taxonium_component/.github/workflows/precommit-checker.yaml @@ -0,0 +1,15 @@ +name: pre-commit + +on: + pull_request: + push: + branches: [master] + +jobs: + pre-commit: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-python@v3 + - uses: pre-commit/action@v3.0.0 + - uses: actions/upload-artifact@v3 diff --git a/taxonium_component/.github/workflows/prettier.yml2 b/taxonium_component/.github/workflows/prettier.yml2 new file mode 100644 index 00000000..b83a5d05 --- /dev/null +++ b/taxonium_component/.github/workflows/prettier.yml2 @@ -0,0 +1,25 @@ +name: Prettier +# This action works with pull requests and pushes +on: + repository_dispatch: + workflow_dispatch: + pull_request: + push: + branches: + - main + +jobs: + prettier: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + # Make sure the actual branch is checked out when running on pull requests + ref: ${{ github.head_ref }} + + - name: Prettify code + uses: creyD/prettier_action@v4.2 + with: + prettier_options: --write **/*.{js,md,jsx} diff --git a/taxonium_component/.github/workflows/python-build.yml b/taxonium_component/.github/workflows/python-build.yml new file mode 100644 index 00000000..1b963345 --- /dev/null +++ b/taxonium_component/.github/workflows/python-build.yml @@ -0,0 +1,35 @@ +name: Publish Python 🐍 distributions 📦 to PyPI and TestPyPI + +on: + push: + paths: + - "taxoniumtools/**" +jobs: + build-n-publish: + name: Build and publish Python 🐍 distributions 📦 to PyPI and TestPyPI + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@master + - name: Set up Python 3.9 + uses: actions/setup-python@v1 + with: + python-version: 3.9 + - name: Install pypa/build + run: >- + python -m + pip install + build + --user + - name: Build a binary wheel and a source tarball + run: >- + python -m + build + --sdist + --wheel + --outdir dist/ + taxoniumtools + - name: Publish distribution 📦 to PyPI + if: startsWith(github.ref, 'refs/tags') + uses: pypa/gh-action-pypi-publish@master + with: + password: ${{ secrets.PYPI_API_KEY }} diff --git a/taxonium_component/.github/workflows/python-format.yaml2 b/taxonium_component/.github/workflows/python-format.yaml2 new file mode 100644 index 00000000..5c7feba4 --- /dev/null +++ b/taxonium_component/.github/workflows/python-format.yaml2 @@ -0,0 +1,28 @@ +name: Formatting python code +on: + push: + paths: + - '**.py' +jobs: + autoyapf: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@master + with: + ref: ${{ github.head_ref }} + - name: autoyapf + id: autoyapf + uses: mritunjaysharma394/autoyapf@v2 + with: + args: --style pep8 --recursive --in-place . + - name: Check for modified files + id: git-check + run: echo ::set-output name=modified::$(if git diff-index --quiet HEAD --; then echo "false"; else echo "true"; fi) + - name: Push changes + if: steps.git-check.outputs.modified == 'true' + run: | + git config --global user.name 'github-actions' + git config --global user.email 'github-actions@github.com' + git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }} + git commit -am "Automated autoyapf fixes" + git push diff --git a/taxonium_component/.github/workflows/python-test.yml b/taxonium_component/.github/workflows/python-test.yml new file mode 100644 index 00000000..0042ec53 --- /dev/null +++ b/taxonium_component/.github/workflows/python-test.yml @@ -0,0 +1,72 @@ +name: Testing Python + +on: + workflow_call: + pull_request: + push: + +jobs: + test: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: [3.8, 3.9, "3.10", 3.11, 3.12] + + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install ./taxoniumtools + - name: Download files + run: | + wget https://github.com/theosanderson/taxonium/raw/master/taxoniumtools/test_data/tfci.meta.tsv.gz + wget https://raw.githubusercontent.com/theosanderson/taxonium/master/taxoniumtools/test_data/hu1.gb + wget https://github.com/theosanderson/taxonium/raw/master/taxoniumtools/test_data/tfci.pb + wget https://github.com/theosanderson/taxonium/raw/master/taxoniumtools/test_data/test_config.json + wget https://github.com/theosanderson/taxonium/raw/master/taxoniumtools/test_data/test.nwk + - name: Basic test + run: | + usher_to_taxonium --input tfci.pb --output tfci-taxonium.jsonl.gz --metadata tfci.meta.tsv.gz --genbank hu1.gb --columns genbank_accession,country,date,pangolin_lineage --clade_types nextstrain,pango + - uses: actions/upload-artifact@v3 + with: + name: tfci-taxonium + path: tfci-taxonium.jsonl.gz + - name: Test with chronumental + run: | + pip install chronumental + usher_to_taxonium --input tfci.pb --output tfci-taxonium-chron.jsonl.gz --metadata tfci.meta.tsv.gz --genbank hu1.gb --columns genbank_accession,country,date,pangolin_lineage --chronumental --chronumental_steps 300 --clade_types nextstrain,pango + - uses: actions/upload-artifact@v3 + with: + name: tfci-taxonium-chron + path: tfci-taxonium-chron.jsonl.gz + - name: Test with config + run: | + usher_to_taxonium --input tfci.pb --output tfci-taxonium-config.jsonl.gz --metadata tfci.meta.tsv.gz --genbank hu1.gb --columns genbank_accession,country,date,pangolin_lineage --config_json test_config.json --name_internal_nodes + - uses: actions/upload-artifact@v3 + with: + name: tfci-taxonium-config + path: tfci-taxonium-config.jsonl.gz + - name: Test no genbank, no metadata + run: | + usher_to_taxonium --input tfci.pb --output tfci-bare.jsonl.gz + - name: Test only varaible sites + run: | + usher_to_taxonium --input tfci.pb --output tfci-var.jsonl.gz --only_variable_sites --metadata tfci.meta.tsv.gz --genbank hu1.gb --columns genbank_accession,country,date,pangolin_lineage + - uses: actions/upload-artifact@v3 + with: + name: tfci-var + path: tfci-var.jsonl.gz + - name: Basic test, nwk + run: | + newick_to_taxonium --input test.nwk --output nwk.jsonl.gz + - uses: LouisBrunner/checks-action@v1.1.1 + if: always() + with: + token: ${{ secrets.GITHUB_TOKEN }} + name: Python tests + conclusion: ${{ job.status }} diff --git a/taxonium_component/.github/workflows/release_npm.yml b/taxonium_component/.github/workflows/release_npm.yml new file mode 100644 index 00000000..34e6f1f4 --- /dev/null +++ b/taxonium_component/.github/workflows/release_npm.yml @@ -0,0 +1,35 @@ +name: Release Taxonium Component + +on: + release: + types: [created] +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Check out code + uses: actions/checkout@v2 + + - name: Use Node.js + uses: actions/setup-node@v2 + with: + node-version: 18 + + - name: Install jq + run: sudo apt-get install jq + + - name: Update package version and release + run: | + cd taxonium_component + TAG_NAME=${GITHUB_REF#refs/tags/} + echo "Current tag is $TAG_NAME" + jq ".version = \"$TAG_NAME\"" package.json > package.json.tmp && mv package.json.tmp package.json + yarn install + yarn build + echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ~/.npmrc + npm publish + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + NODE_OPTIONS: --max-old-space-size=4096