Skip to content

Commit

Permalink
chore: updated actions
Browse files Browse the repository at this point in the history
  • Loading branch information
Mah Neh committed Sep 21, 2024
1 parent 7811c29 commit 4d9b521
Show file tree
Hide file tree
Showing 61 changed files with 4,229 additions and 487 deletions.
3 changes: 2 additions & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
FROM mcr.microsoft.com/devcontainers/python:3.11
FROM mcr.microsoft.com/devcontainers/python:3.12
COPY --from=ghcr.io/astral-sh/uv:latest /uv /bin/uv
COPY setup.sh /setup.sh
4 changes: 2 additions & 2 deletions .devcontainer/setup.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
sudo pip install --upgrade pip
sudo pip install -e ".[tensorflow-cpu,dev]"
#!/bin/env bash
uv sync
pre-commit install
30 changes: 0 additions & 30 deletions .github/ISSUE_TEMPLATE/bug_report.md

This file was deleted.

8 changes: 0 additions & 8 deletions .github/ISSUE_TEMPLATE/custom.md

This file was deleted.

28 changes: 0 additions & 28 deletions .github/ISSUE_TEMPLATE/feature_request.md

This file was deleted.

190 changes: 89 additions & 101 deletions .github/workflows/actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Tests

on:
push:
branches: [master]
branches: [main]
pull_request:
release:
types: [created]
Expand All @@ -11,116 +11,104 @@ permissions:
contents: read

jobs:
build: # builds, caches the packages, runs tests.
name: Test the code with keras
lint-and-format:
name: Lint, format, test example
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Get pip cache dir
id: pip-cache
run: |
python -m pip install --upgrade pip setuptools build
echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT
- name: pip cache
uses: actions/cache@v4

- name: Install uv
uses: astral-sh/setup-uv@v3
id: setup-uv
with:
path: ${{ steps.pip-cache.outputs.dir }}
key: ${{ runner.os }}-pip-${{ hashFiles('pyproject.toml') }}
- name: Install dependencies
run: |
pip install -e ".[dev, backends]" --progress-bar off --upgrade
- name: Test with pytest
run: |
pytest --cov=keras_tuner --cov-report xml:coverage.xml
- name: Codecov
uses: codecov/codecov-action@v4
multibackend:
name: Test the code with Keras Core
enable-cache: true
version: "0.4.14"
github-token: ${{ secrets.GITHUB_TOKEN }}
# Note that astral-sh/setup-uv will automatically use a separate cache key for each host architecture and platform.
- name: Install Python 3.10
uses: uv python install 3.10
- name: Install the project
run: uv sync --all-extras --no-progress
- name: Lint
run: uv run -- ruff check --extend-select I --fix
- name: Format
run: uv run -- ruff format
- name: run example
run: uv example.py

tensorflow:
name: single backend test across python versions.
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
backend: [tensorflow, jax, torch]
runs-on: ubuntu-latest
python-version:
- "3.10"
- "3.11"
- "3.12"
fail-fast: false

steps:
- uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Get pip cache dir
id: pip-cache
run: |
python -m pip install --upgrade pip setuptools
echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT
- name: pip cache
uses: actions/cache@v4

- name: Install uv
uses: astral-sh/setup-uv@v3
id: setup-uv
with:
path: ${{ steps.pip-cache.outputs.dir }}
key: ${{ runner.os }}-pip-${{ hashFiles('setup.py') }}
- name: Install dependencies
run: |
pip install -e ".[dev,backends]" --progress-bar off --upgrade
- name: Test with pytest
enable-cache: true
version: "0.4.14"

- name: Install Python ${{ matrix.python-version }}
run: uv python install ${{matrix.python-version}}

- name: Install the project
run: uv sync --all-extras --no-progress
- name: Do something if the cache was restored
if: steps.setup-uv.outputs.cache-hit == 'true'
run: echo "Cache was restored"

- name: Test with PyTest
env:
KERAS_BACKEND: ${{ matrix.backend }}
KERAS_BACKEND: "tensorflow" # not needed, but for the future.
run: |
pytest --cov=keras_tuner --cov-report xml:coverage.xml
uv run -- pytest --cov=keras_tuner --cov-report xml:coverage.xml
- name: Codecov
uses: codecov/codecov-action@v3
format:
name: Check the code format
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Get pip cache dir
id: pip-cache
run: |
python -m pip install --upgrade pip setuptools
echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT
- name: pip cache
uses: actions/cache@v4
with:
path: ${{ steps.pip-cache.outputs.dir }}
key: ${{ runner.os }}-pip-${{ hashFiles('pyproject.toml') }}
- name: Install dependencies
run: |
pip install -e ".[tensorflow>=2.17,dev]" --progress-bar off --upgrade
- name: Lint
run: bash shell/lint_format.sh
deploy:
needs: [build, format, multibackend]
if: github.event_name == 'release' && github.event.action == 'created'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Get pip cache dir
id: pip-cache
run: |
python -m pip install --upgrade pip setuptools
echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT
- name: pip cache
uses: actions/cache@v4
with:
path: ${{ steps.pip-cache.outputs.dir }}
key: ${{ runner.os }}-pip-${{ hashFiles('pyproject.toml') }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip build setuptools wheel twine
- name: Build a binary wheel and a source tarball
run: python -m build
- name: Publish distribution to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
- uses: codecov/codecov-action@v4
with:
password: ${{ secrets.PYPI_PASSWORD }}
fail_ci_if_error: true # optional (default = false)
files: ./coverage.xml # optional
name: keras_tuner # optional
token: ${{ secrets.GITHUB_TOKEN }} # required
verbose: true # optional (default = false)


# test-multibackend:
# name: Multibackend, multi-python test.
# runs-on: ubuntu-latest

# strategy:
# matrix:
# python-version:
# - "3.10"
# - "3.11"
# - "3.12"
# backend: [tensorflow, jax, torch]
# fail-fast: false

# steps:
# - uses: actions/checkout@v4

# - name: Install uv
# uses: astral-sh/setup-uv@v2

# - name: Set up Python ${{ matrix.python-version }}
# uses: actions/setup-python@v5
# with:
# python-version: ${{matrix.python-version}}
# - name: Install the project
# run: uv sync --all-extras --dev

# - name: Test with PyTest
# env:
# KERAS_BACKEND: ${{ matrix.backend }}
# run: uv run -- pytest
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ docs/sources
.venv
dist
hello
**/*.h5
Loading

0 comments on commit 4d9b521

Please sign in to comment.