diff --git a/.github/workflows/concrete_python_release_cpu.yml b/.github/workflows/concrete_python_release_cpu.yml index 138936042d..54fb10a521 100644 --- a/.github/workflows/concrete_python_release_cpu.yml +++ b/.github/workflows/concrete_python_release_cpu.yml @@ -38,25 +38,6 @@ jobs: backend: aws profile: release - release-checks: - needs: setup-instance - runs-on: ${{ needs.setup-instance.outputs.runner-name }} - steps: - - name: Checkout - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - with: - submodules: recursive - fetch-depth: 0 - - name: Check python api doc is up to date - run: ci/scripts/make_apidocs.sh - - name: Slack Notification - if: ${{ failure() }} - continue-on-error: true - uses: rtCamp/action-slack-notify@c33737706dea87cd7784c687dadc9adf1be59990 - env: - SLACK_COLOR: ${{ job.status }} - SLACK_MESSAGE: "release-checks finished with status: ${{ job.status }}. (${{ env.ACTION_RUN_URL }})" - build-linux-x86: strategy: matrix: @@ -138,6 +119,48 @@ jobs: SLACK_COLOR: ${{ job.status }} SLACK_MESSAGE: "build-linux-x86 finished with status: ${{ job.status }}. (${{ env.ACTION_RUN_URL }})" + release-checks: + strategy: + matrix: + python-version: ["3.8"] + needs: [ build-linux-x86 ] + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + with: + submodules: recursive + fetch-depth: 0 + - name: Setup Python + uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0 + with: + python-version: ${{ matrix.python-version }} + - name: Download wheels + uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 + with: + name: ${{ format('wheel-{0}-linux-x86', matrix.python-version) }} + path: ${{ format('wheel-{0}-linux-x86', matrix.python-version) }} + - name: Check documentation + run: | + WHEEL_DIR=$(pwd)/${{ format('wheel-{0}-linux-x86', matrix.python-version) }} + CONCRETE_WHEEL="${WHEEL_DIR}"/*.whl .github/workflows/scripts/make_apidocs.sh + - name: Upload docs.patch if failure + if: ${{ failure() }} + uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0 + with: + name: docs-artifacts + path: | + docs.patch + docs/dev/api + retention-days: 3 + - name: Slack Notification + if: ${{ failure() }} + continue-on-error: true + uses: rtCamp/action-slack-notify@c33737706dea87cd7784c687dadc9adf1be59990 + env: + SLACK_COLOR: ${{ job.status }} + SLACK_MESSAGE: "release-checks finished with status: ${{ job.status }}. (${{ env.ACTION_RUN_URL }})" + build-macos: strategy: matrix: diff --git a/.github/workflows/scripts/make_apidocs.sh b/.github/workflows/scripts/make_apidocs.sh new file mode 100755 index 0000000000..053656261f --- /dev/null +++ b/.github/workflows/scripts/make_apidocs.sh @@ -0,0 +1,67 @@ +#!/usr/bin/env bash + +set -e + +PYTHON=${PYTHON:-python} +PIP=${PIP:-${PYTHON} -m pip} +VENV_DIR=${PWD}/.venv-docs + +# Remove old documentation +rm -rf docs/dev/api/* + +# Create virtual env and install concrete and docs tools +${PYTHON} -m venv "${VENV_DIR}" +source "${VENV_DIR}"/bin/activate +if [ -z "${CONCRETE_WHEEL}" ]; then + echo "You must specify the CONCRETE_WHEEL environment variable" + exit 1 +fi +${PIP} install ${CONCRETE_WHEEL} +${PIP} install lazydocs + +# Generate the API doc +lazydocs --output-path="./docs/dev/api" --overview-file="README.md" --src-base-url="../../" --no-watermark concrete + + +# Update documentation paths +SED_OPT='-i' +if [ $(uname) == "Darwin" ]; then + SED_OPT='-i ""' +fi + +# Fixing the path issues, to point on files in GitHub +WHICH_PYTHON_VERSION=$(${PYTHON} --version | cut -f 2 -d " " | cut -f 1-2 -d ".") +sed $SED_OPT -e "s@../../.venvtrash/lib.*/python$WHICH_PYTHON_VERSION/site-packages/@../../../compilers/concrete-compiler/compiler/lib/Bindings/Python/@g" docs/dev/api/concrete.compiler*.md docs/dev/api/concrete.lang*.md +sed $SED_OPT -e "s@../../.venvtrash/lib.*/python$WHICH_PYTHON_VERSION/site-packages/@../../frontends/concrete-python/@g" docs/dev/api/concrete.fhe*.md + +# Fixing the links in README.md, which fails (missing .'s for some reason): remove the #headers +sed $SED_OPT -e "s@.md#module-.*)@.md)@g" docs/dev/api/README.md +sed $SED_OPT -e "s@.md#function-.*)@.md)@g" docs/dev/api/README.md +sed $SED_OPT -e "s@.md#class-.*)@.md)@g" docs/dev/api/README.md + +# Removed the "object addresses" and "function addresses", since they are not constant +sed $SED_OPT -e "s@object at 0x[a-zA-Z0-9]*@object at ADDRESS@g" docs/*.md +sed $SED_OPT -e "s@object at 0x[a-zA-Z0-9]*@object at ADDRESS@g" docs/*/*.md +sed $SED_OPT -e "s@object at 0x[a-zA-Z0-9]*@object at ADDRESS@g" docs/*/*/*.md + +sed $SED_OPT -e "s@function Int at 0x[a-zA-Z0-9]*@function Int at ADDRESS@g" docs/*.md +sed $SED_OPT -e "s@function Int at 0x[a-zA-Z0-9]*@function Int at ADDRESS@g" docs/*/*.md +sed $SED_OPT -e "s@function Int at 0x[a-zA-Z0-9]*@function Int at ADDRESS@g" docs/*/*/*.md + +# FIXME: remove this once the PR has been merged once +sed $SED_OPT -e "s@https://github.com/zama-ai/concrete-compiler-internal/blob/main/LICENSE.txt@https://github.com/zama-ai/concrete/blob/main/LICENSE.txt@g" ./docs/dev/api/concrete.lang.dialects.md ./docs/dev/api/concrete.compiler.md ./docs/dev/api/concrete.lang.md + +# Create the patch file +git add -N docs/dev/api/* +git diff docs &> docs.patch + +# Was there changes? +if [ ! -s docs.patch ]; then + echo "The documentation us up to date, congrats." + exit 0 +else + echo "There is a difference in the docs, please commit the changes, here the change:" + cat docs.patch + exit 1 +fi + diff --git a/ci/scripts/make_apidocs.sh b/ci/scripts/make_apidocs.sh deleted file mode 100755 index 08dc3fa8fc..0000000000 --- a/ci/scripts/make_apidocs.sh +++ /dev/null @@ -1,81 +0,0 @@ -#!/usr/bin/env bash - -# In this script, we: -# create a fresh directory -# create a fresh venv -# download the last CP -# make API docs for it - -FRESH_DIRECTORY="tempdirectoryforapidocs" - -# Keep a copy of the doc, to check changes -rm -rf docs-copy -cp -r docs docs-copy - -# Remote old files -rm docs/dev/api/*.md - -set -e - -# Make a new fresh venv, and install the last public CP there (hence, the --isolated to not take -# nightlies) -rm -rf "$FRESH_DIRECTORY" -mkdir "$FRESH_DIRECTORY" -cd "$FRESH_DIRECTORY" -python3 -m venv .venvtrash -source .venvtrash/bin/activate -pip install concrete-python --index-url https://pypi.org/simple --isolated -pip install lazydocs - -# Make API doc files -.venvtrash/bin/lazydocs --output-path="../docs/dev/api" --overview-file="README.md" --src-base-url="../../" --no-watermark concrete -cd - - -rm -rf "$FRESH_DIRECTORY" - -# New files? -echo "Warning. You might have new API-doc files to git add & push, don't forget" - -SED_OPT='-i' -if [ $(uname) == "Darwin" ]; then - SED_OPT='-i ""' -fi - -# Fixing the path issues, to point on files in GitHub -WHICH_PYTHON_VERSION=$(python3 --version | cut -f 2 -d " " | cut -f 1-2 -d ".") -sed $SED_OPT -e "s@../../$FRESH_DIRECTORY/.venvtrash/lib.*/python$WHICH_PYTHON_VERSION/site-packages/@../../../compilers/concrete-compiler/compiler/lib/Bindings/Python/@g" docs/dev/api/concrete.compiler*.md docs/dev/api/concrete.lang*.md -sed $SED_OPT -e "s@../../$FRESH_DIRECTORY/.venvtrash/lib.*/python$WHICH_PYTHON_VERSION/site-packages/@../../frontends/concrete-python/@g" docs/dev/api/concrete.fhe*.md - -# Fixing absolute path in doc -sed $SED_OPT -e "s@$PWD/$FRESH_DIRECTORY/@./@g" docs/dev/api/concrete.compiler.library_support.md - -# Fixing the links in README.md, which fails (missing .'s for some reason): remove the #headers -sed $SED_OPT -e "s@.md#module-.*)@.md)@g" docs/dev/api/README.md -sed $SED_OPT -e "s@.md#function-.*)@.md)@g" docs/dev/api/README.md -sed $SED_OPT -e "s@.md#class-.*)@.md)@g" docs/dev/api/README.md - -# Removed the "object addresses" and "function addresses", since they are not constant -sed $SED_OPT -e "s@object at 0x[a-zA-Z0-9]*@object at ADDRESS@g" docs/*.md -sed $SED_OPT -e "s@object at 0x[a-zA-Z0-9]*@object at ADDRESS@g" docs/*/*.md -sed $SED_OPT -e "s@object at 0x[a-zA-Z0-9]*@object at ADDRESS@g" docs/*/*/*.md - -sed $SED_OPT -e "s@function Int at 0x[a-zA-Z0-9]*@function Int at ADDRESS@g" docs/*.md -sed $SED_OPT -e "s@function Int at 0x[a-zA-Z0-9]*@function Int at ADDRESS@g" docs/*/*.md -sed $SED_OPT -e "s@function Int at 0x[a-zA-Z0-9]*@function Int at ADDRESS@g" docs/*/*/*.md - -# FIXME: remove this once the PR has been merged once -sed $SED_OPT -e "s@https://github.com/zama-ai/concrete-compiler-internal/blob/main/LICENSE.txt@https://github.com/zama-ai/concrete/blob/main/LICENSE.txt@g" ./docs/dev/api/concrete.lang.dialects.md ./docs/dev/api/concrete.compiler.md ./docs/dev/api/concrete.lang.md - -# Was there changes? -if diff -r docs docs-copy; then - echo "" -else - echo "There is a difference in the docs, please commit the changes" - exit -1 -fi - -# If there were changes, the previous command will stop, thanks to set -e -rm -rf docs-copy - -echo "Successful end" -