Skip to content

Commit

Permalink
WIP cleaning up
Browse files Browse the repository at this point in the history
  • Loading branch information
hadim committed Oct 27, 2023
1 parent 2fcacd1 commit 82dc445
Show file tree
Hide file tree
Showing 5 changed files with 236 additions and 86 deletions.
23 changes: 19 additions & 4 deletions .github/workflows/code-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,25 @@ jobs:
- name: Install black
run: |
pip install black>=23
pip install ruff
- name: Lint
run: black --check .

python-lint-ruff:
name: Python lint [ruff]
runs-on: ubuntu-latest
steps:
- name: Checkout the code
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"

- name: Install ruff
run: |
black --check .
ruff check .
pip install ruff
- name: Lint
run: ruff .
125 changes: 92 additions & 33 deletions .github/workflows/doc.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
name: doc
name: release

on:
push:
branches: ["main"]
workflow_dispatch:
inputs:
release-version:
description: "A valid Semver version string"
required: true

# Prevent doc action on `main` to conflict with each others.
concurrency:
group: doc-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: write
pull-requests: write

jobs:
doc:
runs-on: "ubuntu-latest"
release:
# Do not release if not triggered from the default branch
if: github.ref == format('refs/heads/{0}', github.event.repository.default_branch)

runs-on: ubuntu-latest
timeout-minutes: 30

defaults:
Expand All @@ -22,46 +27,100 @@ jobs:
- name: Checkout the code
uses: actions/checkout@v3

# deploy on gh-pages
- name: Setup mamba
uses: mamba-org/setup-micromamba@v1
with:
environment-file: env.yml
environment-name: safe
environment-name: my_env
cache-environment: true
cache-downloads: true
create-args: >-
pip
semver
python-build
setuptools_scm
- name: Install library
run: python -m pip install --no-deps .
- name: Check the version is valid semver
run: |
RELEASE_VERSION="${{ inputs.release-version }}"
{
pysemver check $RELEASE_VERSION
} || {
echo "The version '$RELEASE_VERSION' is not a valid Semver version string."
echo "Please use a valid semver version string. More details at https://semver.org/"
echo "The release process is aborted."
exit 1
}
- name: Check the version is higher than the latest one
run: |
# Retrieve the git tags first
git fetch --prune --unshallow --tags &> /dev/null
RELEASE_VERSION="${{ inputs.release-version }}"
LATEST_VERSION=$(git describe --abbrev=0 --tags)
IS_HIGHER_VERSION=$(pysemver compare $RELEASE_VERSION $LATEST_VERSION)
if [ "$IS_HIGHER_VERSION" != "1" ]; then
echo "The version '$RELEASE_VERSION' is not higher than the latest version '$LATEST_VERSION'."
echo "The release process is aborted."
exit 1
fi
- name: Build Changelog
id: github_release
uses: mikepenz/release-changelog-builder-action@v4
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
toTag: "main"

- name: Configure git
run: |
git config --global user.name "${GITHUB_ACTOR}"
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com"
- name: Deploy the doc
- name: Create and push git tag
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo "Get the gh-pages branch"
git fetch origin gh-pages
# Tag the release
git tag -a "${{ inputs.release-version }}" -m "Release version ${{ inputs.release-version }}"
echo "Build and deploy the doc on main"
mike deploy --push --force main
# Checkout the git tag
git checkout "${{ inputs.release-version }}"
# TODO(EN): REMOVE THIS PART WHEN PUBLIC
# also deploy on valdoc
- name: Fetch Valence Actions
uses: actions/checkout@v3
# Push the modified changelogs
git push origin main
# Push the tags
git push origin "${{ inputs.release-version }}"
- name: Install library
run: python -m pip install --no-deps .

- name: Build the wheel and sdist
run: python -m build --no-isolation

- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository: valence-platform/valence-actions
ref: latest
token: ${{ secrets.VALENCE_GITHUB_TOKEN_PLATFORM }}
path: .github/valence-actions
password: ${{ secrets.PYPI_API_TOKEN }}
packages-dir: dist/

- name: Build and deploy the documentation
uses: ./.github/valence-actions/deploy-valdoc
- name: Create GitHub Release
uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844
with:
env-name: safe
env-file: env.yml
anaconda-token: ${{ secrets.INVIVOAI_ANACONDA_USER_BOT_TOKEN }}
valdoc-json-key: ${{ secrets.VALDOC_WRITE_JSON_KEY }}
doc-name: safe
tag_name: ${{ inputs.release-version }}
body: ${{steps.github_release.outputs.changelog}}

- name: Deploy the doc
run: |
echo "Get the gh-pages branch"
git fetch origin gh-pages
echo "Build and deploy the doc on ${{ inputs.release-version }}"
mike deploy --push --force stable
mike deploy --push --force ${{ inputs.release-version }}
26 changes: 13 additions & 13 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,24 @@ on:
branches:
- "*"
- "!gh-pages"
schedule:
- cron: "0 4 * * MON"

jobs:
build-test:
test:
strategy:
fail-fast: false
matrix:
python-version: ["3.10"]
os: ["ubuntu-latest"] #, "macos-latest", "windows-latest"]
pytorch-version: ["2.0"]
python-version: ["3.11"]

runs-on: ${{ matrix.os }}
runs-on: "ubuntu-latest"
timeout-minutes: 30

defaults:
run:
shell: bash -l {0}

name: |
os=${{ matrix.os }}
- python=${{ matrix.python-version }}
- pytorch=${{ matrix.pytorch-version }}
name: python=${{ matrix.python-version }}

steps:
- name: Checkout the code
Expand All @@ -42,13 +40,15 @@ jobs:
cache-downloads: true
create-args: >-
python=${{ matrix.python-version }}
pytorch=${{ matrix.pytorch-version }}
- name: Install library
run: python -m pip install --no-deps .
run: python -m pip install --no-deps -e .

- name: Run pytest
- name: Run tests
run: pytest

- name: Run doc building
- name: Test CLI
run: safe --help

- name: Test building the doc
run: mkdocs build
Loading

0 comments on commit 82dc445

Please sign in to comment.