diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cacee95..f2d49d3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,8 +5,44 @@ on: push: branches: [main] +concurrency: + group: ${{ github.event_name == 'pull_request' && format('ci-ci-pr-{0}', github.event.pull_request.number) || format('ci-ci-run-{0}', github.run_id) }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} + jobs: + changes: + if: github.event_name == 'pull_request' + runs-on: ubuntu-latest + timeout-minutes: 2 + permissions: + pull-requests: read + outputs: + run: ${{ steps.filter.outputs.run }} + steps: + - id: filter + env: + GH_TOKEN: ${{ github.token }} + PR_NUMBER: ${{ github.event.pull_request.number }} + PR_HEAD: ${{ github.event.pull_request.head.sha }} + CHANGED_FILES: ${{ github.event.pull_request.changed_files }} + shell: bash + run: | + set -euo pipefail + if gh api --paginate --slurp "repos/$GITHUB_REPOSITORY/pulls/$PR_NUMBER/files?per_page=100" > "$RUNNER_TEMP/changes.json" && + jq -e --argjson count "$CHANGED_FILES" ' + add as $files | + ($files | length) == $count and $count > 0 and + all($files[]; all([.filename, (.previous_filename // .filename)][]; test("^README[.]md$"))) + ' "$RUNNER_TEMP/changes.json" >/dev/null && + test "$(gh api "repos/$GITHUB_REPOSITORY/pulls/$PR_NUMBER" --jq .head.sha)" = "$PR_HEAD"; then + echo 'run=false' >> "$GITHUB_OUTPUT" + else + echo 'run=true' >> "$GITHUB_OUTPUT" + fi + verify: + needs: changes + if: ${{ !cancelled() && needs.changes.outputs.run != 'false' }} runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v7.0.1 @@ -20,8 +56,17 @@ jobs: - run: pnpm install --frozen-lockfile - name: Install shells for installer tests run: | - sudo apt-get update - sudo apt-get install -y --no-install-recommends zsh fish + missing=() + for shell in zsh fish; do + command -v "$shell" >/dev/null || missing+=("$shell") + done + if (( ${#missing[@]} )); then + if ! sudo apt-get -o Acquire::Retries=0 install -y --no-install-recommends "${missing[@]}"; then + sudo apt-get update + sudo apt-get install -y --no-install-recommends "${missing[@]}" + fi + fi + command -v zsh fish - run: pnpm release:audit - uses: actions/upload-artifact@v7.0.2 with: @@ -29,6 +74,8 @@ jobs: path: release/ dsh-latest: + needs: changes + if: ${{ !cancelled() && needs.changes.outputs.run != 'false' }} runs-on: ubuntu-24.04 env: DSH_TEST_PREFIX: /tmp/agentonweb-dsh-latest @@ -49,7 +96,17 @@ jobs: - name: Install the latest DSH and an isolated test browser run: | npm install --prefix "$DSH_TEST_PREFIX" --no-audit --no-fund @deepseek-ai/dsh@latest playwright-core - node "$DSH_TEST_PREFIX/node_modules/playwright-core/cli.js" install --with-deps chromium + playwright="$DSH_TEST_PREFIX/node_modules/playwright-core/cli.js" + node "$playwright" install chromium --no-shell + if ! xvfb-run -a node <<'NODE' + const { chromium } = require(process.env.DSH_TEST_PREFIX + '/node_modules/playwright-core'); + chromium.launch({ headless: false, timeout: 10000 }) + .then((browser) => browser.close()) + .catch((error) => { console.warn(error.message); process.exitCode = 1; }); + NODE + then + node "$playwright" install-deps chromium + fi - name: Verify latest DSH plugin, settings UI and cookie authentication run: | chromium_executable=$(node -e 'console.log(require(process.env.DSH_TEST_PREFIX + "/node_modules/playwright-core").chromium.executablePath())')