diff --git a/.github/workflows/pull-request.yml b/.github/workflows/add-pr-assignee.yml similarity index 94% rename from .github/workflows/pull-request.yml rename to .github/workflows/add-pr-assignee.yml index 58cf9cad4..c6570c0aa 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/add-pr-assignee.yml @@ -1,9 +1,11 @@ +name: Add PR assignee + on: pull_request: types: [opened] jobs: - add-assignee: + add-pr-assignee: runs-on: ubuntu-latest permissions: pull-requests: write diff --git a/.github/workflows/backend.yml b/.github/workflows/backend.yml index af8f89418..4f7e2d8d4 100644 --- a/.github/workflows/backend.yml +++ b/.github/workflows/backend.yml @@ -1,54 +1,75 @@ -name: Backend +name: Reusable backend workflow -on: - pull_request: - paths: - - 'src/**' - - 'tests/**' - - 'pyproject.toml' - - 'Makefile' - - 'requirements*.txt' - - '.github/workflows/backend.yml' - -permissions: - contents: read +on: [workflow_call] jobs: - lint-backend: + build-frontend: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 + - uses: actions/setup-node@v4 with: - python-version: '3.12' - cache: 'pip' - - name: Lint backend + node-version: '20' + cache: 'npm' + cache-dependency-path: frontend/package-lock.json + - shell: bash run: | - python -m pip install --upgrade pip - python -m pip install --upgrade pre-commit + cd frontend - pre-commit run --all-files ruff + npm install + npm run build + npm run build:lib -- --emptyOutDir false + - uses: actions/upload-artifact@v4 + with: + name: frontend-package-distributions + path: frontend/dist test-backend: runs-on: ubuntu-latest + needs: build-frontend + strategy: + fail-fast: true + matrix: + python-version: ['3.11', '3.12'] + steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: - python-version: '3.12' + python-version: ${{ matrix.python-version }} cache: 'pip' - - name: Build frontend and share library - shell: bash - run: make build-frontend - - name: Build package distributions + + - name: Lint run: | python -m pip install --upgrade pip + python -m pip install --upgrade pre-commit + pre-commit run --all-files ruff + + - name: Download package distributions + uses: actions/download-artifact@v4 + with: + name: frontend-package-distributions + path: src/skore/ui/static + + - name: Build + run: | python -m pip install --upgrade build python -m build + - name: Install run: | python -m pip install dist/*.whl --no-dependencies python -m pip install -r requirements.txt -r requirements-test.txt - - name: Pytest + + - name: Test timeout-minutes: 5 run: python -m pytest + + cleanup: + runs-on: ubuntu-latest + if: always() + needs: test-backend + steps: + - uses: geekyeggo/delete-artifact@v5 + with: + name: frontend-package-distributions diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 000000000..195c653f3 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,58 @@ +name: CI + +on: [pull_request] + +jobs: + changes: + runs-on: ubuntu-latest + outputs: + backend: ${{ steps.filter.outputs.backend }} + frontend: ${{ steps.filter.outputs.frontend }} + permissions: + pull-requests: read + steps: + - uses: dorny/paths-filter@v3 + id: filter + with: + filters: | + backend: + - 'src/**' + - 'tests/**' + - 'pyproject.toml' + - 'requirements*.txt' + - '.github/workflows/backend.yml' + frontend: + - 'frontend/**' + - '.github/workflows/frontend.yml' + + lint-all-files: + uses: ./.github/workflows/lint.yml + permissions: + contents: read + + lint-and-test-backend: + needs: [lint-all-files, changes] + if: ${{ needs.changes.outputs.backend == 'true' }} + uses: ./.github/workflows/backend.yml + permissions: + contents: read + + lint-and-test-frontend: + needs: [lint-all-files, changes] + if: ${{ needs.changes.outputs.frontend == 'true' }} + uses: ./.github/workflows/frontend.yml + permissions: + contents: read + pull-requests: write + + ci-all-green: + needs: + - lint-all-files + - lint-and-test-backend + - lint-and-test-frontend + if: ${{ always() }} + runs-on: Ubuntu-latest + steps: + - shell: bash + run: | + [[ ${{ contains(needs.*.result, 'failure') }} = false ]] diff --git a/.github/workflows/frontend.yml b/.github/workflows/frontend.yml index 841ecc490..ad3874c91 100644 --- a/.github/workflows/frontend.yml +++ b/.github/workflows/frontend.yml @@ -1,15 +1,6 @@ -name: Frontend +name: Reusable frontend workflow -on: - pull_request: - paths: - - 'frontend/**' - - Makefile - - .github/workflows/frontend.yml - -permissions: - contents: read - pull-requests: write +on: [workflow_call] jobs: lint-frontend: @@ -33,6 +24,7 @@ jobs: test-frontend: runs-on: ubuntu-latest + needs: lint-frontend steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 @@ -43,6 +35,7 @@ jobs: - name: Test frontend run: | cd frontend + npm install npm run test:unit:coverage - name: Report coverage @@ -64,4 +57,9 @@ jobs: cache-dependency-path: frontend/package-lock.json - name: Build frontend shell: bash - run: make build-frontend + run: | + cd frontend + + npm install + npm run build + npm run build:lib -- --emptyOutDir false diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index e8099edc0..07e7eb1c1 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,9 +1,6 @@ -name: Lint +name: Reusable lint workflow -on: [pull_request] - -permissions: - contents: read +on: [workflow_call] jobs: lint-all-files: