diff --git a/.github/workflows/documentation_codeblock_tests.yml b/.github/workflows/documentation_codeblock_tests.yml index a3cd6dac1d..83d6228d44 100644 --- a/.github/workflows/documentation_codeblock_tests.yml +++ b/.github/workflows/documentation_codeblock_tests.yml @@ -10,8 +10,13 @@ on: options: - 'false' - 'true' - schedule: - - cron: '0 0 * * *' # Run once a day at midnight UTC + pull_request: + paths: + - 'apps/opik-documentation/documentation/docs/*.md' + - 'apps/opik-documentation/documentation/docs/*.mdx' + - 'apps/opik-documentation/documentation/docs/**/*.md' + - 'apps/opik-documentation/documentation/docs/**/*.mdx' + jobs: collect_test_paths: runs-on: ubuntu-latest @@ -19,14 +24,30 @@ jobs: test_paths: ${{ steps.paths.outputs.paths }} steps: - uses: actions/checkout@v3 + with: + fetch-depth: 0 # Fetch all history for git diff + - id: paths working-directory: apps/opik-documentation/documentation run: | - # Collect both directories and markdown files in root - ( - ls -d docs/*/ 2>/dev/null; - find docs -maxdepth 1 -type f -name "*.md" - ) | jq --raw-input --slurp --compact-output 'split("\n")[:-1]' >> ${GITHUB_OUTPUT} + # Get list of changed files in docs directory + if [[ "${{ github.event_name }}" == "pull_request" ]]; then + # For pull requests, compare with base branch + echo "paths=$( + git diff --name-only origin/${{ github.base_ref }} | + grep -E '^apps/opik-documentation/documentation/docs/.*\.(md|mdx)$' | + sed 's|apps/opik-documentation/documentation/||' | + jq -R -s -c 'split("\n")[:-1]' + )" >> $GITHUB_OUTPUT + else + # For manual runs and scheduled runs, check all files + echo "paths=$( + ( + ls -d docs/*/ 2>/dev/null; + find docs -maxdepth 1 -type f -name "*.md" -o -name "*.mdx" + ) | jq -R -s -c 'split("\n")[:-1]' + )" >> $GITHUB_OUTPUT + fi test: needs: collect_test_paths @@ -44,9 +65,11 @@ jobs: python-version: '3.10' - name: Install dependencies + working-directory: apps/opik-documentation/documentation run: | python -m pip install --upgrade pip pip install pytest + pip install -r requirements.txt if [ "${{ github.event.inputs.install_opik }}" = "true" ]; then pip install -e . fi @@ -54,4 +77,6 @@ jobs: - name: Run tests working-directory: apps/opik-documentation/documentation run: | - pytest ${{ matrix.path }} -v + if [ -n "${{ matrix.path }}" ]; then + pytest ${{ matrix.path }} -v --suppress-no-test-exit-code + fi diff --git a/apps/opik-documentation/documentation/requirements.txt b/apps/opik-documentation/documentation/requirements.txt index 87906ccb40..b920daf862 100644 --- a/apps/opik-documentation/documentation/requirements.txt +++ b/apps/opik-documentation/documentation/requirements.txt @@ -1 +1,4 @@ -jupyter \ No newline at end of file +jupyter +markdown-analysis +pytest-asyncio +pytest-custom_exit_code diff --git a/apps/opik-documentation/documentation/sidebars.ts b/apps/opik-documentation/documentation/sidebars.ts index 4c42861003..aa727536b1 100644 --- a/apps/opik-documentation/documentation/sidebars.ts +++ b/apps/opik-documentation/documentation/sidebars.ts @@ -42,7 +42,6 @@ const sidebars: SidebarsConfig = { "tracing/log_distributed_traces", "tracing/annotate_traces", "tracing/cost_tracking", - "tracing/production_monitoring", "tracing/sdk_configuration", "tracing/export_data", { @@ -116,7 +115,7 @@ const sidebars: SidebarsConfig = { type: "category", label: "Production", collapsed: true, - items: ["production/gateway"], + items: ["production/gateway", "production/production_monitoring"], }, { type: "category",