From 00462a51f029a25ab9e83cb4348bfe570e0b9e15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9lina?= Date: Mon, 18 Nov 2024 15:36:19 +0100 Subject: [PATCH] Add CI workflow to auto-generate api inference documentation (#1480) * Add ci workflow to auto-generate api inference doc * Update token * add permissions section * change pnpm installation gh action * fix pnpm installation * change working directory * revert * hopefully good * trying with other versions * new tests * pnpm version * do not update .lock file * don't update lock file * fix * explicit package.json * fix lock file * implcit * explicit * update pnpm ? * daily cron job * update huggingface/tasks before generating docs * run workflow on this branch to test * revert to cron job and update PR body --------- Co-authored-by: Wauplin --- .../api_inference_generate_documentation.yml | 64 +++++++++++++++++++ scripts/api-inference/package.json | 1 + 2 files changed, 65 insertions(+) create mode 100644 .github/workflows/api_inference_generate_documentation.yml diff --git a/.github/workflows/api_inference_generate_documentation.yml b/.github/workflows/api_inference_generate_documentation.yml new file mode 100644 index 000000000..52ba04303 --- /dev/null +++ b/.github/workflows/api_inference_generate_documentation.yml @@ -0,0 +1,64 @@ +name: Update API Inference Documentation + +on: + workflow_dispatch: + schedule: + - cron: "0 3 * * *" # Every day at 3am + +concurrency: + group: api_inference_generate_documentation + cancel-in-progress: true + +jobs: + pull_request: + runs-on: ubuntu-latest + steps: + # Setup + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: "20" + - name: Install pnpm + uses: pnpm/action-setup@v2 + with: + run_install: | + - recursive: true + cwd: ./scripts/api-inference + args: [--frozen-lockfile] + package_json_file: ./scripts/api-inference/package.json + - name: Update huggingface/tasks package + working-directory: ./scripts/api-inference + run: | + pnpm update @huggingface/tasks@latest + # Generate + - name: Generate API inference documentation + run: pnpm run generate + working-directory: ./scripts/api-inference + + # Check changes + - name: Check changes + run: git status + + # Create or update Pull Request + - name: Create Pull Request + uses: peter-evans/create-pull-request@v7 + with: + token: ${{ secrets.TOKEN_INFERENCE_SYNC_BOT }} + commit-message: Update API inference documentation (automated) + branch: update-api-inference-docs-automated-pr + delete-branch: true + title: "[Bot] Update API inference documentation" + body: | + This PR automatically upgrades the `@huggingface/tasks` package and regenerates the API inference documentation by running: + ```sh + cd scripts/api-inference + pnpm update @huggingface/tasks@latest + pnpm run generate + ``` + + This PR was automatically created by the [Update API Inference Documentation workflow](https://github.com/huggingface/hub-docs/blob/main/.github/workflows/api_inference_generate_documentation.yml). + + Please review the changes before merging. + reviewers: | + Wauplin + hanouticelina \ No newline at end of file diff --git a/scripts/api-inference/package.json b/scripts/api-inference/package.json index c8e317ca5..26eede48e 100644 --- a/scripts/api-inference/package.json +++ b/scripts/api-inference/package.json @@ -1,5 +1,6 @@ { "name": "api-inference-generator", + "packageManager": "pnpm@9.7.1", "version": "1.0.0", "description": "", "main": "index.js",