qwen-code/scripts/tests/release-workflow.test.js
Shaojin Wen f5b0a85dcf
ci: auto-update ECS runners on stable publish and harden update job (#8343)
* ci: dispatch npm-published on stable release and harden runner update

The update-ecs-runner-qwen workflow declares a repository_dispatch
npm-published trigger, but nothing in the repo ever sent that event,
so the self-hosted ECS runners only picked up new qwen releases when
someone remembered to run the update workflow by hand. Emit the
dispatch from the release workflow after a stable (npm_tag=latest)
publish, carrying the released version; dispatch failure only warns so
an already-published release cannot be failed by it.

Also harden the update job against npm ENOTEMPTY rename failures: all
runner processes of a region share one machine, so a concurrent global
npm install from another job can race the npm rename of the package
dir. Clear stale npm trash dirs and retry up to three times with
backoff.

* ci(triage): pin action qwen reinstall to the installed version

The triage job's qwen-code-action runs an unconditional global
npm install with --prefer-offline on every run. On the shared
self-hosted ECS box that resolves the latest dist-tag from the
persistent npm cache, which lags npm publishes: after the runners
were updated to 0.21.3, the next triage job resolved latest as the
cached 0.21.2 and downgraded the box, which then also re-created the
stale npm trash dir that blocks the update workflow with ENOTEMPTY.

Capture the version the Ensure qwen CLI step verified and pass it as
qwen_cli_version, so the action's redundant reinstall targets the
exact installed version (no dist-tag resolution) and can never
downgrade the shared runner.

* ci: harden npm-published dispatch and runner update retry (#8343)

* test(ci): scope workflow assertions and add triage version-pin test (#8343)

* test(ci): pin retry-loop structure in runner update workflow test (#8343)

---------

Co-authored-by: qwen-code-ci-bot <qwen-code-ci@service.alibaba.com>
Co-authored-by: qwen-code-dev-bot <qwen-code-dev-bot@users.noreply.github.com>
Co-authored-by: qwen-code-ci-bot <qwen-code-ci-bot@users.noreply.github.com>
2026-08-02 03:33:52 +00:00

42 lines
1.7 KiB
JavaScript

/**
* @license
* Copyright 2026 Qwen Team
* SPDX-License-Identifier: Apache-2.0
*/
import { readFileSync } from 'node:fs';
import { describe, expect, it } from 'vitest';
const workflow = readFileSync('.github/workflows/release.yml', 'utf8');
describe('release workflow', () => {
it('fires the fleet-moving npm-published dispatch on stable releases only', () => {
// This gate is the sole protection keeping a nightly/preview/dry-run
// release from moving the ECS fleet; the triggered update workflow
// installs whatever version it is handed, so there is no downstream
// guard. Pin all three clauses together so dropping or inverting one
// fails review instead of silently shipping a non-stable fleet.
expect(workflow).toContain(
'if: |-\n' +
" ${{ github.repository == 'QwenLM/qwen-code' &&\n" +
" needs.prepare.outputs.is_dry_run == 'false' &&\n" +
" needs.prepare.outputs.npm_tag == 'latest' }}",
);
expect(workflow).toContain("-f 'event_type=npm-published'");
expect(workflow).toContain(
'-f "client_payload[version]=${RELEASE_VERSION}"',
);
});
it('keeps a dispatch failure from failing an already-published release', () => {
// The packages are published before this step runs, so it must not fail
// the release; but the failure must still surface (as an error, not a
// warning) so the fleet can be reconciled via a manual re-run.
expect(workflow).toContain(
'continue-on-error: true\n' +
' env:\n' +
" GITHUB_TOKEN: '${{ secrets.CI_BOT_PAT }}'",
);
expect(workflow).toContain('echo "::error::npm-published dispatch failed;');
});
});