Skip to content

Commit

Permalink
feat: support using pkg.pr.new releases
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Aug 16, 2024
1 parent 337b8ed commit 9304172
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 55 deletions.
23 changes: 20 additions & 3 deletions .github/workflows/ecosystem-ci-from-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ on:
required: true
type: string
default: "vuejs/core"
commit:
description: "commit to use"
type: string
suite:
description: "testsuite to run. runs all testsuits when `-`."
required: false
Expand Down Expand Up @@ -83,14 +86,21 @@ jobs:
- run: corepack enable
- run: pnpm --version
- run: pnpm i --frozen-lockfile
- run: >-

- if: ${{ !inputs.commit }}
run: >-
pnpm tsx ecosystem-ci.ts
--branch ${{ inputs.branchName }}
--repo ${{ inputs.repo }}
${{ inputs.suite }}
env:
COREPACK_ENABLE_STRICT: 0

- if: ${{ inputs.commit }}
run: pnpm tsx ecosystem-ci.ts --commit ${{ inputs.commit }} ${{ inputs.suite }}
env:
COREPACK_ENABLE_STRICT: 0

execute-all:
timeout-minutes: 60
runs-on: ubuntu-latest
Expand Down Expand Up @@ -125,11 +135,18 @@ jobs:
- run: corepack enable
- run: pnpm --version
- run: pnpm i --frozen-lockfile
- run: >-

- if: ${{ !inputs.commit }}
run: >-
pnpm tsx ecosystem-ci.ts
--branch ${{ inputs.branchName }}
--repo ${{ inputs.repo }}
${{ matrix.suite }}
${{ inputs.suite }}
env:
COREPACK_ENABLE_STRICT: 0

- if: ${{ inputs.commit }}
run: pnpm tsx ecosystem-ci.ts --commit ${{ inputs.commit }} ${{ inputs.suite }}
env:
COREPACK_ENABLE_STRICT: 0

Expand Down
24 changes: 0 additions & 24 deletions .github/workflows/ecosystem-ci-selected.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,30 +62,6 @@ jobs:
node-version: 20.14.0
id: setup-node

- name: Download built packages (branch)
if: inputs.refType == 'branch'
uses: dawidd6/action-download-artifact@v4
with:
repo: ${{ inputs.repo }}
workflow: upload-packages.yml
branch: ${{ inputs.ref }}
name: packages
github_token: ${{ secrets.ECOSYSTEM_CI_ACCESS_TOKEN }}
path: built-packages
if_no_artifact_found: warn

- name: Download built packages (commit)
if: inputs.refType == 'commit'
uses: dawidd6/action-download-artifact@v4
with:
repo: ${{ inputs.repo }}
workflow: upload-packages.yml
commit: ${{ inputs.ref }}
name: packages
github_token: ${{ secrets.ECOSYSTEM_CI_ACCESS_TOKEN }}
path: built-packages
if_no_artifact_found: warn

- run: corepack enable
- run: pnpm --version
- run: pnpm i --frozen-lockfile
Expand Down
24 changes: 0 additions & 24 deletions .github/workflows/ecosystem-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,30 +65,6 @@ jobs:
node-version: 20.14.0
id: setup-node

- name: Download built packages (branch)
if: inputs.refType == 'branch' || github.event_name == 'schedule'
uses: dawidd6/action-download-artifact@v4
with:
repo: ${{ github.event_name == 'schedule' && 'vuejs/core' || inputs.repo }}
workflow: upload-packages.yml
branch: ${{ github.event_name == 'schedule' && 'main' || inputs.ref }}
name: packages
github_token: ${{ secrets.ECOSYSTEM_CI_ACCESS_TOKEN }}
path: built-packages
if_no_artifact_found: warn

- name: Download built packages (commit)
if: inputs.refType == 'commit'
uses: dawidd6/action-download-artifact@v4
with:
repo: ${{ inputs.repo }}
workflow: upload-packages.yml
commit: ${{ inputs.ref }}
name: packages
github_token: ${{ secrets.ECOSYSTEM_CI_ACCESS_TOKEN }}
path: built-packages
if_no_artifact_found: warn

- run: corepack enable
- run: pnpm --version
- run: pnpm i --frozen-lockfile
Expand Down
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

This repository is used to run integration tests for vue ecosystem projects

## How it works

We now have continuous release like [this](https://github.com/vuejs/core/runs/28854321865) via [pkg.pr.new](https://github.com/stackblitz-labs/pkg.pr.new). By default when running against a branch or a commit, we will use the corresponding release from `pkg.pr.new` so we don't need to build / mock publish the packages again.

We will use pnpm override to force install the specific version of Vue in the downstream projects and then run their tests.

In cases where we cannot use pre-built packages, the script will perform a fresh build by pulling the specific Vue branch / commit and publish them to a local verdaccio registry.

## via github workflow

### scheduled
Expand Down Expand Up @@ -32,6 +40,19 @@ The repositories are checked out into `workspace` subdirectory as shallow clones

If you want to test the same version of vue multiple times, please run `pnpm clean` first to ensure the workspace is clean.

### Running against local build

To run against the local build, link the `packages` directory of a local `vuejs/core` clone to `built-packages` inside this repo, then run with the `--local` option.

### Explicitly running against pkg.pr.new releases

You can run against a specific continuous release via `--release @<commit or branch>`. For example:

```
tsx ecosystem-ci.ts --release @main
tsx ecosystem-ci.ts --release @ca41b9202
```

## how to add a new integration test

- check out the existing [tests](./tests) and add one yourself. Thanks to some utilities it is really easy
Expand Down
16 changes: 14 additions & 2 deletions ecosystem-ci.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@ cli
.option('--branch <branch>', 'vue branch to use', { default: 'main' })
.option('--tag <tag>', 'vue tag to use')
.option('--commit <commit>', 'vue commit sha to use')
.option('--release <version>', 'vue release to use from npm registry')
.option('--local', 'test locally')
.option(
'--release <version>',
'vue release to use from npm registry or pkg.pr.new.',
)
.option('--local', 'test locally (expects built-packages to be present)')
.action(async (suites, options: CommandOptions) => {
const { root, vuePath, workspace } = await setupEnvironment()
const suitesToRun = getSuitesToRun(suites, root)
Expand All @@ -31,6 +34,15 @@ cli
// Need to setup the Vue repo to get the package names
await setupVueRepo(options)

// Normalize branch / commit to pkg.pr.new releases
if (!options.release && !options.tag && !options.local) {
if (options.commit) {
options.release = `@${options.commit.slice(0, 7)}`
} else if (options.repo === 'vuejs/core' && options.branch) {
options.release = `@${options.branch}`
}
}

if (options.release) {
vueVersion = options.release
} else {
Expand Down
9 changes: 7 additions & 2 deletions utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -301,8 +301,13 @@ export async function runInRepo(options: RunOptions & RepoOptions) {
const vuePackages = await getVuePackages()

if (options.release) {
// pkg.pr.new support
for (const pkg of vuePackages) {
if (overrides[pkg.name] && overrides[pkg.name] !== options.release) {
let version = options.release
if (options.release.startsWith('@')) {
version = `https://pkg.pr.new/${pkg.name}@${options.release.slice(1)}`
}
if (overrides[pkg.name] && overrides[pkg.name] !== version) {
throw new Error(
`conflicting overrides[${pkg.name}]=${
overrides[pkg.name]
Expand All @@ -311,7 +316,7 @@ export async function runInRepo(options: RunOptions & RepoOptions) {
} config. Use either one or the other`,
)
} else {
overrides[pkg.name] = options.release
overrides[pkg.name] = version
}
}
} else {
Expand Down

0 comments on commit 9304172

Please sign in to comment.