Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(package.json): move astro from dependencies to peerDependencies #668

Merged
merged 19 commits into from
Oct 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
138289b
fix(package.json): move astro from dependencies to peerDependencies
risu729 Oct 5, 2024
b7feada
Merge remote-tracking branch 'origin/main' into 657-loose-dependencie…
risu729 Oct 5, 2024
c17502a
chore(knip.config.ts): enable astro plugin manually
risu729 Oct 5, 2024
9c0261d
test(tests/e2e/fixtures/package.json): add astro to dependencies
risu729 Oct 5, 2024
cb01e6b
test(tests/e2e/fixtures/bun.lockb): update lockfile
risu729 Oct 5, 2024
2e990ca
chore(knip.config.ts): remove ignoreBinaries in test fixtures workspace
risu729 Oct 5, 2024
ed0cc46
fix(package.json): add carets to dependency versions
risu729 Oct 5, 2024
8bfa7c9
fix(package.json): loose peerDependencies version constraint and add …
risu729 Oct 5, 2024
0454ac2
chore(renovate.json5): disable version pinning for dependencies and p…
risu729 Oct 5, 2024
0736f60
ci(.github/workflows/e2e.yml): handle multiple versions of astro
risu729 Oct 5, 2024
5cc8cf4
ci(.github/workflows/lint.yml): add job to conclude the result
risu729 Oct 5, 2024
04df973
ci(.github/workflows/lint.yml): run actions-timeline after lint-status
risu729 Oct 5, 2024
b703b91
ci(.github/workflows/lint.yml): handle skipped and cancelled status f…
risu729 Oct 5, 2024
c9a6b3b
ci(.github/workflows/lint.yml): fix if statement in bash script
risu729 Oct 5, 2024
849832d
ci(.github/workflows/lint.yml): fix check status bash script
risu729 Oct 5, 2024
12a132d
ci(.github/workflows/lint.yml): split actions-timeline job
risu729 Oct 5, 2024
cbb294e
Merge branch 'main' into 657-loose-dependencies-version
risu729 Oct 6, 2024
ed63515
ci(.github/workflows/e2e.yml): test several astro versions in the fix…
risu729 Oct 6, 2024
db11387
fix(package.json): narrow astro peerDependencies range
risu729 Oct 6, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 70 additions & 4 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,55 @@ defaults:
shell: bash

jobs:
list-astro-versions:
runs-on: ubuntu-24.04
timeout-minutes: 10
permissions:
contents: read # for checkout

outputs:
astro-versions: ${{ steps.list.outputs.versions }}

steps:
- name: Checkout
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0

- name: Install mise
uses: jdx/mise-action@f8dfbcc150159126838e44b882bf34bd98fd90f3 # v2.1.0
with:
experimental: true
install: false

- name: Install mise tools
# cspell:ignore reshim
# reshim is required to avoid "No such file or directory" error
# ref: https://github.com/jdx/mise/issues/2260
run: mise install || (mise reshim && mise install)

- name: Install package.json dependencies
run: mise run buni

- name: List astro versions for E2E tests
id: list
run: |
versions=$(bun run .github/workflows/scripts/list-astro-versions.ts)
echo "versions=$versions" >> "$GITHUB_OUTPUT"

test-e2e-general:
needs:
- list-astro-versions

runs-on: ubuntu-24.04
timeout-minutes: 10
permissions:
contents: read # for checkout

name: test-e2e-general-astro-${{ matrix.version }}
strategy:
fail-fast: false
matrix:
version: ${{ fromJson(needs.list-astro-versions.outputs.astro-versions) }}

steps:
- name: Checkout
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
Expand All @@ -43,7 +86,7 @@ jobs:
run: mise run build

- name: Install E2E Test Fixtures Dependencies
run: bun install --frozen-lockfile
run: bun install astro@${{ matrix.version }}
working-directory: tests/e2e/fixtures

- name: Build E2E Test Fixtures with astro-better-image-service
Expand Down Expand Up @@ -89,7 +132,7 @@ jobs:
if: failure() && steps.playwright-test.outcome == 'failure'
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0
with:
name: playwright-report-${{ github.sha }}
name: playwright-report-astro-${{ matrix.version }}-${{ github.sha }}
path: playwright-report/

test-e2e-conversion:
Expand Down Expand Up @@ -124,7 +167,12 @@ jobs:
id: dependency-versions
run: |
playwright_version=$(bun pm ls | sed -nE 's/.*@playwright\/test@(.+)/\1/p')
astro_version=$(bun pm ls | sed -nE 's/.*astro@(.+)/\1/p')
astro_version=$(bun pm ls | sed -nE 's/.*astro@(.+)/\1/p' | uniq)
# throw error if several versions are found
if [[ $(echo "$astro_version" | wc -l) -gt 1 ]]; then
echo "Multiple versions of Astro found: $astro_version"
exit 1
fi
echo "playwright=$playwright_version" >> "$GITHUB_OUTPUT"
echo "astro=$astro_version" >> "$GITHUB_OUTPUT"

Expand Down Expand Up @@ -203,14 +251,32 @@ jobs:
name: playwright-report-conversion-${{ github.sha }}
path: playwright-report/

actions-timeline:
test-e2e-status:
needs:
- test-e2e-general
- test-e2e-conversion

# skip if the workflow is called from another workflow
if: ${{ !cancelled() && contains(github.workflow_ref, '/e2e.yml') }}

runs-on: ubuntu-24.04
timeout-minutes: 5

steps:
- name: Check the status of the jobs
run: |
if [[ $(echo '${{ toJson(needs.*.result) }}' | jq 'all(. == "success")') == "false" ]]; then
echo 'Some jobs are failed, cancelled, or skipped.'
exit 1
fi
echo 'All jobs are successful.'

actions-timeline:
needs:
- test-e2e-status

if: needs.test-e2e-status.result == 'success' || needs.test-e2e-status.result == 'failure'

runs-on: ubuntu-24.04
timeout-minutes: 5
permissions:
Expand Down
20 changes: 19 additions & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -148,14 +148,32 @@ jobs:
if: steps.commitlint-push-initial.outcome == 'skipped' && steps.commitlint-push.outcome == 'skipped' && steps.commitlint-pr.outcome == 'skipped'
run: bun run commitlint --verbose --from ${{ github.sha }}~1 --to ${{ github.sha }}

actions-timeline:
lint-status:
needs:
- lint
- lint-commitlint

# skip if the workflow is called from another workflow
if: ${{ !cancelled() && contains(github.workflow_ref, '/lint.yml') }}

runs-on: ubuntu-24.04
timeout-minutes: 5

steps:
- name: Check the status of the jobs
run: |
if [[ $(echo '${{ toJson(needs.*.result) }}' | jq 'all(. == "success")') == "false" ]]; then
echo 'Some jobs are failed, cancelled, or skipped.'
exit 1
fi
echo 'All jobs are successful.'

actions-timeline:
needs:
- lint-status

if: needs.lint-status.result == 'success' || needs.lint-status.result == 'failure'

runs-on: ubuntu-24.04
timeout-minutes: 5
permissions:
Expand Down
38 changes: 38 additions & 0 deletions .github/workflows/scripts/list-astro-versions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { $ } from "bun";
import { compare, parse, satisfies } from "semver";
import packageJson from "../../../package.json" with { type: "json" };

$.throws(true);

const peerRange = packageJson.peerDependencies.astro as string;

const versions = (await $`npm view astro versions --json`.json()) as string[];

const versionsInRange = versions
.filter((version) => satisfies(version, peerRange))
.sort(compare);

const groupedVersions = Object.groupBy(versionsInRange, (version) => {
const semver = parse(version);
if (!semver) {
throw new Error(`Invalid version: ${version}`);
}
return `${semver.major}.${semver.minor}`;
});

const versionsToTest = [
...new Set([
// oldest 3 versions
...versionsInRange.slice(0, 3),
// oldest version of each major version
...Object.entries(groupedVersions)
.filter(([key]) => key.endsWith(".0"))
.map(([, versions]) => versions?.at(0)),
// latest version of each minor version
...Object.values(groupedVersions).map((versions) => versions?.at(-1)),
// latest 5 versions
...versionsInRange.slice(-5),
]),
];

console.write(JSON.stringify(versionsToTest));
Binary file modified bun.lockb
Binary file not shown.
6 changes: 4 additions & 2 deletions knip.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,19 @@ const config: KnipConfig = {
workspaces: {
".": {
ignoreDependencies: [
// mise.toml is not recognized by Knip
// mise.toml is not recognized
"@biomejs/biome",
"cspell",
"ignore-sync",
"markdownlint-cli2",
"renovate",
// bun run cannot be detected by Knip
// bun run cannot be detected
"@commitlint/cli",
"semantic-release",
],
entry: ["src/index.ts", "**/scripts/**"],
// peerDependencies are not recognized as plugins
astro: true,
},
"tests/e2e/fixtures": {},
},
Expand Down
10 changes: 7 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@
"prepare": "husky && bun link"
},
"dependencies": {
"astro": "4.15.11",
"sharp": "0.33.5",
"svgo": "3.3.2"
"sharp": "^0.33.5",
"svgo": "^3.3.2"
},
"peerDependencies": {
"astro": "^4.7.0"
},
"devDependencies": {
"@biomejs/biome": "1.9.3",
Expand All @@ -45,6 +47,7 @@
"ajv": "8.17.1",
"ajv-draft-04": "1.0.0",
"ajv-formats": "3.0.1",
"astro": "4.15.11",
"commitizen": "4.3.1",
"cspell": "8.14.4",
"husky": "9.1.6",
Expand All @@ -57,6 +60,7 @@
"prettier": "3.3.3",
"renovate": "38.110.2",
"semantic-release": "24.1.2",
"semver": "7.6.3",
"ts-graphviz": "2.1.4",
"typescript": "5.6.2"
},
Expand Down
17 changes: 17 additions & 0 deletions renovate.json5
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,24 @@
},
],
packageRules: [
// disable pinning for dependencies and peerDependencies
{
matchFileNames: ["package.json"],
matchDepTypes: ["dependencies"],
// bump for dependencies and release a patch update
rangeStrategy: "bump",
},
{
matchFileNames: ["package.json"],
matchDepTypes: ["peerDependencies"],
// widen range for peerDependencies as far as possible
rangeStrategy: "widen",
},
// set semantic commit types
{
matchFileNames: ["tests/"],
semanticCommitType: "test",
},
{
matchCategories: ["ci"],
semanticCommitType: "ci",
Expand Down
Binary file modified tests/e2e/fixtures/bun.lockb
Binary file not shown.
1 change: 1 addition & 0 deletions tests/e2e/fixtures/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"private": true,
"type": "module",
"dependencies": {
"astro": "4.15.11",
"astro-better-image-service": "link:astro-better-image-service"
},
"scripts": {
Expand Down