Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
29 changes: 24 additions & 5 deletions .github/workflows/ci.generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,28 @@ enum Runner {
Windows = "windows-latest",
// uses an older version of ubuntu because of issue dprint/#483
Linux = "ubuntu-20.04",
LinuxArm =
"${{ (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')) && 'buildjet-2vcpu-ubuntu-2204-arm' || 'ubuntu-latest' }}",
}

interface ProfileData {
runner: Runner;
target: string;
runTests?: boolean;
// currently not used
cross?: boolean;
}

function withCondition(
step: Record<string, unknown>,
condition: string,
): Record<string, unknown> {
return {
...step,
if: "if" in step ? `(${condition}) && (${step.if})` : condition,
};
}

const profileDataItems: ProfileData[] = [{
runner: Runner.Mac13,
target: "x86_64-apple-darwin",
Expand All @@ -33,10 +46,9 @@ const profileDataItems: ProfileData[] = [{
target: "x86_64-unknown-linux-gnu",
runTests: true,
}, {
runner: Runner.Linux,
runner: Runner.LinuxArm,
target: "aarch64-unknown-linux-gnu",
runTests: false,
cross: true,
runTests: true,
}];
const profiles = profileDataItems.map((profile) => {
return {
Expand Down Expand Up @@ -116,7 +128,7 @@ const ci = {
if: "matrix.config.cross == 'true'",
run: [
"cd js/node && npm run build:script",
"cargo install cross --locked --git https://github.com/cross-rs/cross --rev 44011c8854cb2eaac83b173cc323220ccdff18ea",
"cargo install cross --locked --git https://github.com/cross-rs/cross --rev 4090beca3cfffa44371a5bba524de3a578aa46c3",
].join("\n"),
},
{
Expand Down Expand Up @@ -170,6 +182,7 @@ const ci = {
`echo \"ZIP_CHECKSUM=$(shasum -a 256 ${profile.zipFileName} | awk '{print $1}')\" >> $GITHUB_OUTPUT`,
];
case Runner.Linux:
case Runner.LinuxArm:
return [
`cd target/${profile.target}/release`,
`zip -r ${profile.zipFileName} dprint-plugin-prettier`,
Expand Down Expand Up @@ -201,7 +214,13 @@ const ci = {
},
};
}),
],
].map((step) =>
withCondition(
step,
// only run arm64 linux on main or tags
"matrix.config.target != 'aarch64-unknown-linux-gnu' || github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')",
)
),
},
draft_release: {
name: "draft_release",
Expand Down
57 changes: 29 additions & 28 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ jobs:
run_tests: "true"
cross: "false"
target: x86_64-unknown-linux-gnu
- os: ubuntu-20.04
run_tests: "false"
cross: "true"
- os: "${{ (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')) && 'buildjet-2vcpu-ubuntu-2204-arm' || 'ubuntu-latest' }}"
run_tests: "true"
cross: "false"
target: aarch64-unknown-linux-gnu
outputs:
ZIP_CHECKSUM_X86_64_APPLE_DARWIN: "${{steps.pre_release_x86_64_apple_darwin.outputs.ZIP_CHECKSUM}}"
Expand All @@ -51,107 +51,113 @@ jobs:
RUST_BACKTRACE: full
steps:
- uses: actions/checkout@v4
if: "matrix.config.target != 'aarch64-unknown-linux-gnu' || github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')"
- uses: dsherret/rust-toolchain-file@v1
if: "matrix.config.target != 'aarch64-unknown-linux-gnu' || github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')"
- name: Cache cargo
uses: Swatinem/rust-cache@v2
with:
prefix-key: "v3-${{matrix.config.target}}"
save-if: "${{ github.ref == 'refs/heads/main' }}"
if: "matrix.config.target != 'aarch64-unknown-linux-gnu' || github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')"
- name: Setup Rust (aarch64-apple-darwin)
if: matrix.config.target == 'aarch64-apple-darwin'
if: "(matrix.config.target != 'aarch64-unknown-linux-gnu' || github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')) && (matrix.config.target == 'aarch64-apple-darwin')"
run: rustup target add aarch64-apple-darwin
- uses: denoland/setup-deno@v2
if: "matrix.config.target != 'aarch64-unknown-linux-gnu' || github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')"
- uses: actions/setup-node@v4
with:
node-version: 21
if: "matrix.config.target != 'aarch64-unknown-linux-gnu' || github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')"
- name: npm install
run: cd js/node && npm ci
if: "matrix.config.target != 'aarch64-unknown-linux-gnu' || github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')"
- name: Setup cross
if: matrix.config.cross == 'true'
if: "(matrix.config.target != 'aarch64-unknown-linux-gnu' || github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')) && (matrix.config.cross == 'true')"
run: |-
cd js/node && npm run build:script
cargo install cross --locked --git https://github.com/cross-rs/cross --rev 44011c8854cb2eaac83b173cc323220ccdff18ea
cargo install cross --locked --git https://github.com/cross-rs/cross --rev 4090beca3cfffa44371a5bba524de3a578aa46c3
- name: Build (Debug)
if: "matrix.config.cross != 'true' && !startsWith(github.ref, 'refs/tags/')"
if: "(matrix.config.target != 'aarch64-unknown-linux-gnu' || github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')) && (matrix.config.cross != 'true' && !startsWith(github.ref, 'refs/tags/'))"
run: "cargo build --locked --all-targets --target ${{matrix.config.target}}"
- name: Build release
if: "matrix.config.cross != 'true' && startsWith(github.ref, 'refs/tags/')"
if: "(matrix.config.target != 'aarch64-unknown-linux-gnu' || github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')) && (matrix.config.cross != 'true' && startsWith(github.ref, 'refs/tags/'))"
run: "cargo build --locked --all-targets --target ${{matrix.config.target}} --release"
- name: Build cross (Debug)
if: "matrix.config.cross == 'true' && !startsWith(github.ref, 'refs/tags/')"
if: "(matrix.config.target != 'aarch64-unknown-linux-gnu' || github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')) && (matrix.config.cross == 'true' && !startsWith(github.ref, 'refs/tags/'))"
run: "cross build --locked --target ${{matrix.config.target}}"
- name: Build cross (Release)
if: "matrix.config.cross == 'true' && startsWith(github.ref, 'refs/tags/')"
if: "(matrix.config.target != 'aarch64-unknown-linux-gnu' || github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')) && (matrix.config.cross == 'true' && startsWith(github.ref, 'refs/tags/'))"
run: "cross build --locked --target ${{matrix.config.target}} --release"
- name: Lint
if: "!startsWith(github.ref, 'refs/tags/') && matrix.config.target == 'x86_64-unknown-linux-gnu'"
if: "(matrix.config.target != 'aarch64-unknown-linux-gnu' || github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')) && (!startsWith(github.ref, 'refs/tags/') && matrix.config.target == 'x86_64-unknown-linux-gnu')"
run: cargo clippy
- name: Test (Debug)
if: "matrix.config.run_tests == 'true' && !startsWith(github.ref, 'refs/tags/')"
if: "(matrix.config.target != 'aarch64-unknown-linux-gnu' || github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')) && (matrix.config.run_tests == 'true' && !startsWith(github.ref, 'refs/tags/'))"
run: cargo test --locked --all-features
- name: Test (Release)
if: "matrix.config.run_tests == 'true' && startsWith(github.ref, 'refs/tags/')"
if: "(matrix.config.target != 'aarch64-unknown-linux-gnu' || github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')) && (matrix.config.run_tests == 'true' && startsWith(github.ref, 'refs/tags/'))"
run: cargo test --locked --all-features --release
- name: Pre-release (x86_64-apple-darwin)
id: pre_release_x86_64_apple_darwin
if: "matrix.config.target == 'x86_64-apple-darwin' && startsWith(github.ref, 'refs/tags/')"
if: "(matrix.config.target != 'aarch64-unknown-linux-gnu' || github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')) && (matrix.config.target == 'x86_64-apple-darwin' && startsWith(github.ref, 'refs/tags/'))"
run: |-
cd target/x86_64-apple-darwin/release
zip -r dprint-plugin-prettier-x86_64-apple-darwin.zip dprint-plugin-prettier
echo "ZIP_CHECKSUM=$(shasum -a 256 dprint-plugin-prettier-x86_64-apple-darwin.zip | awk '{print $1}')" >> $GITHUB_OUTPUT
- name: Pre-release (aarch64-apple-darwin)
id: pre_release_aarch64_apple_darwin
if: "matrix.config.target == 'aarch64-apple-darwin' && startsWith(github.ref, 'refs/tags/')"
if: "(matrix.config.target != 'aarch64-unknown-linux-gnu' || github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')) && (matrix.config.target == 'aarch64-apple-darwin' && startsWith(github.ref, 'refs/tags/'))"
run: |-
cd target/aarch64-apple-darwin/release
zip -r dprint-plugin-prettier-aarch64-apple-darwin.zip dprint-plugin-prettier
echo "ZIP_CHECKSUM=$(shasum -a 256 dprint-plugin-prettier-aarch64-apple-darwin.zip | awk '{print $1}')" >> $GITHUB_OUTPUT
- name: Pre-release (x86_64-pc-windows-msvc)
id: pre_release_x86_64_pc_windows_msvc
if: "matrix.config.target == 'x86_64-pc-windows-msvc' && startsWith(github.ref, 'refs/tags/')"
if: "(matrix.config.target != 'aarch64-unknown-linux-gnu' || github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')) && (matrix.config.target == 'x86_64-pc-windows-msvc' && startsWith(github.ref, 'refs/tags/'))"
run: |-
Compress-Archive -CompressionLevel Optimal -Force -Path target/x86_64-pc-windows-msvc/release/dprint-plugin-prettier.exe -DestinationPath target/x86_64-pc-windows-msvc/release/dprint-plugin-prettier-x86_64-pc-windows-msvc.zip
echo "ZIP_CHECKSUM=$(shasum -a 256 target/x86_64-pc-windows-msvc/release/dprint-plugin-prettier-x86_64-pc-windows-msvc.zip | awk '{print $1}')" >> $GITHUB_OUTPUT
- name: Pre-release (x86_64-unknown-linux-gnu)
id: pre_release_x86_64_unknown_linux_gnu
if: "matrix.config.target == 'x86_64-unknown-linux-gnu' && startsWith(github.ref, 'refs/tags/')"
if: "(matrix.config.target != 'aarch64-unknown-linux-gnu' || github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')) && (matrix.config.target == 'x86_64-unknown-linux-gnu' && startsWith(github.ref, 'refs/tags/'))"
run: |-
cd target/x86_64-unknown-linux-gnu/release
zip -r dprint-plugin-prettier-x86_64-unknown-linux-gnu.zip dprint-plugin-prettier
echo "ZIP_CHECKSUM=$(shasum -a 256 dprint-plugin-prettier-x86_64-unknown-linux-gnu.zip | awk '{print $1}')" >> $GITHUB_OUTPUT
- name: Pre-release (aarch64-unknown-linux-gnu)
id: pre_release_aarch64_unknown_linux_gnu
if: "matrix.config.target == 'aarch64-unknown-linux-gnu' && startsWith(github.ref, 'refs/tags/')"
if: "(matrix.config.target != 'aarch64-unknown-linux-gnu' || github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')) && (matrix.config.target == 'aarch64-unknown-linux-gnu' && startsWith(github.ref, 'refs/tags/'))"
run: |-
cd target/aarch64-unknown-linux-gnu/release
zip -r dprint-plugin-prettier-aarch64-unknown-linux-gnu.zip dprint-plugin-prettier
echo "ZIP_CHECKSUM=$(shasum -a 256 dprint-plugin-prettier-aarch64-unknown-linux-gnu.zip | awk '{print $1}')" >> $GITHUB_OUTPUT
- name: Upload artifacts (x86_64-apple-darwin)
if: "matrix.config.target == 'x86_64-apple-darwin' && startsWith(github.ref, 'refs/tags/')"
if: "(matrix.config.target != 'aarch64-unknown-linux-gnu' || github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')) && (matrix.config.target == 'x86_64-apple-darwin' && startsWith(github.ref, 'refs/tags/'))"
uses: actions/upload-artifact@v4
with:
name: x86_64-apple-darwin-artifacts
path: target/x86_64-apple-darwin/release/dprint-plugin-prettier-x86_64-apple-darwin.zip
- name: Upload artifacts (aarch64-apple-darwin)
if: "matrix.config.target == 'aarch64-apple-darwin' && startsWith(github.ref, 'refs/tags/')"
if: "(matrix.config.target != 'aarch64-unknown-linux-gnu' || github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')) && (matrix.config.target == 'aarch64-apple-darwin' && startsWith(github.ref, 'refs/tags/'))"
uses: actions/upload-artifact@v4
with:
name: aarch64-apple-darwin-artifacts
path: target/aarch64-apple-darwin/release/dprint-plugin-prettier-aarch64-apple-darwin.zip
- name: Upload artifacts (x86_64-pc-windows-msvc)
if: "matrix.config.target == 'x86_64-pc-windows-msvc' && startsWith(github.ref, 'refs/tags/')"
if: "(matrix.config.target != 'aarch64-unknown-linux-gnu' || github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')) && (matrix.config.target == 'x86_64-pc-windows-msvc' && startsWith(github.ref, 'refs/tags/'))"
uses: actions/upload-artifact@v4
with:
name: x86_64-pc-windows-msvc-artifacts
path: target/x86_64-pc-windows-msvc/release/dprint-plugin-prettier-x86_64-pc-windows-msvc.zip
- name: Upload artifacts (x86_64-unknown-linux-gnu)
if: "matrix.config.target == 'x86_64-unknown-linux-gnu' && startsWith(github.ref, 'refs/tags/')"
if: "(matrix.config.target != 'aarch64-unknown-linux-gnu' || github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')) && (matrix.config.target == 'x86_64-unknown-linux-gnu' && startsWith(github.ref, 'refs/tags/'))"
uses: actions/upload-artifact@v4
with:
name: x86_64-unknown-linux-gnu-artifacts
path: target/x86_64-unknown-linux-gnu/release/dprint-plugin-prettier-x86_64-unknown-linux-gnu.zip
- name: Upload artifacts (aarch64-unknown-linux-gnu)
if: "matrix.config.target == 'aarch64-unknown-linux-gnu' && startsWith(github.ref, 'refs/tags/')"
if: "(matrix.config.target != 'aarch64-unknown-linux-gnu' || github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')) && (matrix.config.target == 'aarch64-unknown-linux-gnu' && startsWith(github.ref, 'refs/tags/'))"
uses: actions/upload-artifact@v4
with:
name: aarch64-unknown-linux-gnu-artifacts
Expand Down Expand Up @@ -186,9 +192,6 @@ jobs:
- name: Get tag version
id: get_tag_version
run: 'echo TAG_VERSION=${GITHUB_REF/refs\/tags\//} >> $GITHUB_OUTPUT'
- name: Get prettier version
id: get_prettier_version
run: "echo PRETTIER_VERSION=$(deno run --allow-read scripts/output_prettier_version.ts) >> $GITHUB_OUTPUT"
- name: Get plugin file checksum
id: get_plugin_file_checksum
run: 'echo "CHECKSUM=$(shasum -a 256 plugin.json | awk ''{print $1}'')" >> $GITHUB_OUTPUT'
Expand All @@ -205,8 +208,6 @@ jobs:
dprint-plugin-prettier-aarch64-unknown-linux-gnu.zip
plugin.json
body: |
Prettier ${{ steps.get_prettier_version.outputs.PRETTIER_VERSION }}

## Install

Dependencies:
Expand Down