mirror of
https://github.com/evolutionaryscale/esm.git
synced 2026-06-04 17:14:23 +08:00
adding CI that checks for linting, typechecking, and runs tests
This commit is contained in:
97
.github/workflows/ci.yml
vendored
Normal file
97
.github/workflows/ci.yml
vendored
Normal file
@@ -0,0 +1,97 @@
|
||||
name: ESM Tests
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- "**"
|
||||
workflow_dispatch:
|
||||
merge_group:
|
||||
types: [checks_requested]
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
pull-requests: write
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
test-precommit:
|
||||
runs-on: ubuntu-22.04-16core
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Environment
|
||||
uses: prefix-dev/setup-pixi@v0.8.1
|
||||
with:
|
||||
pixi-version: v0.47.0
|
||||
cache: false
|
||||
cache-write: ${{ github.event_name == 'push' && github.ref_name == 'main' }}
|
||||
|
||||
- name: Check formatting and typing
|
||||
run: |
|
||||
set -e
|
||||
# pyright seems to do something weird at initialization that causes it to error out
|
||||
# We can ignore the first invocation here.
|
||||
pyright esm/__init__.py || true
|
||||
pre-commit install
|
||||
env NODE_OPTIONS="--max-old-space-size=16384" pre-commit run --all-files --show-diff-on-failure
|
||||
[ -z "$(git status --porcelain)" ] && true || (echo "❌❌❌ pre-commit hook failed! A few files changed ❌❌❌]" && git status --porcelain && false)
|
||||
git reset --hard HEAD # test without the pre-commit changes
|
||||
shell: pixi run bash -e {0}
|
||||
|
||||
|
||||
test-esm:
|
||||
runs-on: ubuntu-22.04-16core
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Environment
|
||||
uses: prefix-dev/setup-pixi@v0.8.1
|
||||
with:
|
||||
pixi-version: v0.47.0
|
||||
cache: false
|
||||
cache-write: ${{ github.event_name == 'push' && github.ref_name == 'main' }}
|
||||
|
||||
- name: Run tests
|
||||
run: |
|
||||
set -o pipefail
|
||||
pytest -v --junitxml=pytest.xml tests/ | tee pytest-coverage.txt
|
||||
shell: pixi run bash -e {0}
|
||||
|
||||
- name: Run Docker tests
|
||||
env:
|
||||
DOCKER_TAG: ${{ github.sha }}
|
||||
FORGE_URL: https://forge.evolutionaryscale.ai/
|
||||
run: |
|
||||
set -e
|
||||
cd tests
|
||||
make build-oss-ci
|
||||
make start-docker-oss URL=${{ env.FORGE_URL }} DOCKER_TAG=${{ env.DOCKER_TAG }} ESM3_FORGE_TOKEN=${{ secrets.ESM3_FORGE_TOKEN }}
|
||||
shell: pixi run bash -e {0}
|
||||
|
||||
- name: cleanup docker containers if they're hanging
|
||||
if: ${{ always() }}
|
||||
run: |
|
||||
docker rm --force --volumes $(docker ps -q) || true
|
||||
|
||||
# Next two steps adds a comment to any PR that reports tests + code coverage.
|
||||
- name: Pytest Coverage Comment
|
||||
if: ${{ github.event_name == 'pull_request' }}
|
||||
uses: MishaKav/pytest-coverage-comment@v1.1.47
|
||||
id: coverageComment
|
||||
with:
|
||||
title: Coverage Report
|
||||
pytest-coverage-path: pytest-coverage.txt
|
||||
junitxml-path: pytest.xml
|
||||
report-only-changed-files: true
|
||||
|
||||
- name: Pytest coverage GitHub summary
|
||||
if: ${{ github.event_name == 'pull_request' }}
|
||||
run: |
|
||||
echo '${{ steps.coverageComment.outputs.coverageHtml }}' >> $GITHUB_STEP_SUMMARY
|
||||
Reference in New Issue
Block a user