Skip to content

Commit 61110a5

Browse files
committed
add docs and clean up logic for toolchain override
1 parent d6a86f8 commit 61110a5

File tree

14 files changed

+1012
-31
lines changed

14 files changed

+1012
-31
lines changed

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@ exclude = [
1212
"test/fixtures/02-with-utility",
1313
"test/fixtures/03-with-function",
1414
"test/fixtures/04-with-parameter",
15-
"test/fixtures/05-with-similar-entrypaths"
15+
"test/fixtures/05-with-similar-entrypaths",
16+
"test/fixtures/06-with-toolchain-override"
1617
]

rust-toolchain.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[toolchain]
2+
channel = "nightly"

src/lib/rust-toolchain.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
import { debug } from '@vercel/build-utils';
22
import execa from 'execa';
33

4-
async function downloadRustToolchain({
5-
version = 'stable',
6-
}: {
7-
version?: string;
8-
}): Promise<void> {
4+
async function downloadRustToolchain(): Promise<void> {
95
try {
106
await execa(
11-
`curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain ${version}`,
7+
`curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y`,
128
[],
139
{ shell: true, stdio: 'inherit' },
1410
);
@@ -21,11 +17,11 @@ async function downloadRustToolchain({
2117
}
2218
}
2319

24-
export const installRustToolchain = async (version?: string): Promise<void> => {
20+
export const installRustToolchain = async (): Promise<void> => {
2521
try {
2622
await execa(`rustup -V`, [], { shell: true, stdio: 'ignore' });
2723
debug('Rust Toolchain is already installed, skipping download');
2824
} catch (err) {
29-
await downloadRustToolchain({ version });
25+
await downloadRustToolchain();
3026
}
3127
};

test/fixtures.test.ts

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,12 @@
11
import { join } from 'node:path';
22
import ms from 'ms';
33
import execa from 'execa';
4-
import { writeJSON } from 'fs-extra';
54
import fetch from 'node-fetch';
65

7-
const vercelFileName = 'test.vercel.json';
8-
const pkgRootFile = `file:${process.cwd()}`;
96
const readyRegex = /Ready!\s+Available at (?<url>https?:\/\/\w+:\d+)/;
107

118
jest.setTimeout(ms('50m'));
129

13-
interface Config {
14-
builds: {
15-
use: string;
16-
}[];
17-
}
18-
1910
interface Probe {
2011
path: string;
2112
status?: number;
@@ -30,19 +21,6 @@ async function importJSON<T>(path: string): Promise<T> {
3021
return (await import(path)) as unknown as Promise<T>;
3122
}
3223

33-
async function injectConf(confPath: string): Promise<Config> {
34-
const conf = await importJSON<Config>(join(confPath, vercelFileName));
35-
36-
conf.builds[0].use = pkgRootFile;
37-
38-
await writeJSON(join(confPath, 'vercel.json'), conf, {
39-
spaces: 2,
40-
EOL: '\n',
41-
});
42-
43-
return conf;
44-
}
45-
4624
async function checkProbes(baseUrl: string, probes: Probe[]): Promise<void> {
4725
for (const probe of probes) {
4826
// eslint-disable-next-line no-await-in-loop
@@ -121,4 +99,7 @@ describe('vercel-rust', () => {
12199
it('deploy 05-with-similar-entrypaths', async () => {
122100
await expect(testFixture('05-with-similar-entrypaths')).resolves.toBe('ok');
123101
});
102+
it('deploy 06-with-toolchain-override', async () => {
103+
await expect(testFixture('06-with-toolchain-override')).resolves.toBe('ok');
104+
});
124105
});
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.vercel
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
target/

0 commit comments

Comments
 (0)