Skip to content

Commit 3c0f2db

Browse files
committed
Auto merge of #17118 - Veykril:linked-rust-files, r=Veykril
feat: Allow rust files to be used linkedProjects With this, script files become more usable as the user can at least add them manually to the linked projects, allowing them to be used "on the (manual) fly" without having to open a separate vscode window that only has files open and no folder. Also makes build scripts work for them (though no proc-macros, for some reason the dylib field is not populated in the output)
2 parents 55d9a53 + 7c39263 commit 3c0f2db

File tree

1,986 files changed

+494483
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,986 files changed

+494483
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[alias]
2+
xtask = "run --package xtask --bin xtask --"
3+
tq = "test -- -q"
4+
qt = "tq"
5+
lint = "clippy --all-targets -- --cap-lints warn"
6+
codegen = "run --package xtask --bin xtask -- codegen"
7+
8+
[target.x86_64-pc-windows-msvc]
9+
linker = "rust-lld"
10+
11+
[env]
12+
CARGO_WORKSPACE_DIR = { value = "", relative = true }

src/tools/rust-analyzer/.editorconfig

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# https://EditorConfig.org
2+
root = true
3+
4+
[*]
5+
charset = utf-8
6+
trim_trailing_whitespace = true
7+
end_of_line = lf
8+
insert_final_newline = true
9+
indent_style = space
10+
indent_size = 4
11+
max_line_length = 100
12+
13+
[*.md]
14+
indent_size = 2
15+
16+
[*.{yml, yaml}]
17+
indent_size = 2
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# for this file to take effect make sure you use git ^2.23 and
2+
# add ignoreFile to your git configuration:
3+
# ```
4+
# git config --global blame.ignoreRevsFile .git-blame-ignore-revs
5+
# ```
6+
7+
# prettier format
8+
f247090558c9ba3c551566eae5882b7ca865225f
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
* text=auto eol=lf
2+
3+
# git grep shouldn't match entries in this benchmark data
4+
bench_data/** binary
5+
6+
# Older git versions try to fix line endings on images, this prevents it.
7+
*.png binary
8+
*.jpg binary
9+
*.ico binary
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
---
2+
name: Bug report
3+
about: Create a bug report for rust-analyzer.
4+
title: ''
5+
labels: 'C-bug'
6+
assignees: ''
7+
8+
---
9+
10+
<!--
11+
Troubleshooting guide: https://rust-analyzer.github.io/manual.html#troubleshooting
12+
Forum for questions: https://users.rust-lang.org/c/ide/14
13+
14+
Before submitting, please make sure that you're not running into one of these known issues:
15+
16+
1. on-the-fly diagnostics are mostly unimplemented (`cargo check` diagnostics will be shown when saving a file): #3107
17+
18+
Otherwise please try to provide information which will help us to fix the issue faster. Minimal reproducible examples with few dependencies are especially lovely <3.
19+
-->
20+
21+
**rust-analyzer version**: (eg. output of "rust-analyzer: Show RA Version" command, accessible in VSCode via <kbd>Ctrl/⌘</kbd>+<kbd>Shift</kbd>+<kbd>P</kbd>)
22+
23+
**rustc version**: (eg. output of `rustc -V`)
24+
25+
**editor or extension**: (eg. VSCode, Vim, Emacs, etc. For VSCode users, specify your extension version; for users of other editors, provide the distribution if applicable)
26+
27+
**relevant settings**: (eg. client settings, or environment variables like `CARGO`, `RUSTC`, `RUSTUP_HOME` or `CARGO_HOME`)
28+
29+
**repository link (if public, optional)**: (eg. [rust-analyzer](https://github.com/rust-lang/rust-analyzer))
30+
31+
**code snippet to reproduce**:
32+
```rust
33+
// add your code here
34+
35+
```
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
name: Critical Nightly Regression
3+
about: You are using nightly rust-analyzer and the latest version is unusable.
4+
title: ''
5+
labels: 'Broken Window'
6+
assignees: ''
7+
8+
---
9+
10+
<!--
11+
Troubleshooting guide: https://rust-analyzer.github.io/manual.html#troubleshooting
12+
13+
Please try to provide information which will help us to fix the issue faster. Minimal reproducible examples with few dependencies are especially lovely <3.
14+
-->
15+
16+
This is a serious regression in nightly and it's important to fix it before the next release.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
name: Feature Request
3+
about: Create a feature request for rust-analyzer.
4+
title: ''
5+
labels: 'C-feature'
6+
assignees: ''
7+
8+
---
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
name: Support Question
3+
about: A question regarding functionality of rust-analyzer.
4+
title: ''
5+
labels: 'C-support'
6+
assignees: ''
7+
8+
---
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
FROM node:slim
2+
3+
COPY . /action
4+
WORKDIR /action
5+
6+
RUN npm install --production
7+
8+
ENTRYPOINT ["node", "/action/main.js"]
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# github-release
2+
3+
Copy-pasted from
4+
https://github.com/bytecodealliance/wasmtime/tree/8acfdbdd8aa550d1b84e0ce1e6222a6605d14e38/.github/actions/github-release
5+
6+
An action used to publish GitHub releases for `wasmtime`.
7+
8+
As of the time of this writing there's a few actions floating around which
9+
perform github releases but they all tend to have their set of drawbacks.
10+
Additionally nothing handles deleting releases which we need for our rolling
11+
`dev` release.
12+
13+
To handle all this, this action rolls its own implementation using the
14+
actions/toolkit repository and packages published there. These run in a Docker
15+
container and take various inputs to orchestrate the release from the build.
16+
17+
More comments can be found in `main.js`.
18+
19+
Testing this is really hard. If you want to try though run `npm install` and
20+
then `node main.js`. You'll have to configure a bunch of env vars though to get
21+
anything reasonably working.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: 'wasmtime github releases'
2+
description: 'wasmtime github releases'
3+
inputs:
4+
token:
5+
description: ''
6+
required: true
7+
name:
8+
description: ''
9+
required: true
10+
files:
11+
description: ''
12+
required: true
13+
runs:
14+
using: 'docker'
15+
image: 'Dockerfile'
Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
const core = require('@actions/core');
2+
const path = require("path");
3+
const fs = require("fs");
4+
const github = require('@actions/github');
5+
const glob = require('glob');
6+
7+
function sleep(milliseconds) {
8+
return new Promise(resolve => setTimeout(resolve, milliseconds));
9+
}
10+
11+
async function runOnce() {
12+
// Load all our inputs and env vars. Note that `getInput` reads from `INPUT_*`
13+
const files = core.getInput('files');
14+
const name = core.getInput('name');
15+
const token = core.getInput('token');
16+
const slug = process.env.GITHUB_REPOSITORY;
17+
const owner = slug.split('/')[0];
18+
const repo = slug.split('/')[1];
19+
const sha = process.env.HEAD_SHA;
20+
21+
core.info(`files: ${files}`);
22+
core.info(`name: ${name}`);
23+
24+
const options = {
25+
request: {
26+
timeout: 30000,
27+
}
28+
};
29+
const octokit = github.getOctokit(token, options);
30+
31+
// Delete the previous release since we can't overwrite one. This may happen
32+
// due to retrying an upload or it may happen because we're doing the dev
33+
// release.
34+
const releases = await octokit.paginate("GET /repos/:owner/:repo/releases", { owner, repo });
35+
for (const release of releases) {
36+
if (release.tag_name !== name) {
37+
continue;
38+
}
39+
const release_id = release.id;
40+
core.info(`deleting release ${release_id}`);
41+
await octokit.rest.repos.deleteRelease({ owner, repo, release_id });
42+
}
43+
44+
// We also need to update the `dev` tag while we're at it on the `dev` branch.
45+
if (name == 'nightly') {
46+
try {
47+
core.info(`updating nightly tag`);
48+
await octokit.rest.git.updateRef({
49+
owner,
50+
repo,
51+
ref: 'tags/nightly',
52+
sha,
53+
force: true,
54+
});
55+
} catch (e) {
56+
core.error(e);
57+
core.info(`creating nightly tag`);
58+
await octokit.rest.git.createTag({
59+
owner,
60+
repo,
61+
tag: 'nightly',
62+
message: 'nightly release',
63+
object: sha,
64+
type: 'commit',
65+
});
66+
}
67+
}
68+
69+
// Creates an official GitHub release for this `tag`, and if this is `dev`
70+
// then we know that from the previous block this should be a fresh release.
71+
core.info(`creating a release`);
72+
const release = await octokit.rest.repos.createRelease({
73+
owner,
74+
repo,
75+
name,
76+
tag_name: name,
77+
target_commitish: sha,
78+
prerelease: name === 'nightly',
79+
});
80+
const release_id = release.data.id;
81+
82+
// Upload all the relevant assets for this release as just general blobs.
83+
for (const file of glob.sync(files)) {
84+
const size = fs.statSync(file).size;
85+
const name = path.basename(file);
86+
87+
await runWithRetry(async function () {
88+
// We can't overwrite assets, so remove existing ones from a previous try.
89+
let assets = await octokit.rest.repos.listReleaseAssets({
90+
owner,
91+
repo,
92+
release_id
93+
});
94+
for (const asset of assets.data) {
95+
if (asset.name === name) {
96+
core.info(`delete asset ${name}`);
97+
const asset_id = asset.id;
98+
await octokit.rest.repos.deleteReleaseAsset({ owner, repo, asset_id });
99+
}
100+
}
101+
102+
core.info(`upload ${file}`);
103+
const headers = { 'content-length': size, 'content-type': 'application/octet-stream' };
104+
const data = fs.createReadStream(file);
105+
await octokit.rest.repos.uploadReleaseAsset({
106+
data,
107+
headers,
108+
name,
109+
url: release.data.upload_url,
110+
});
111+
});
112+
}
113+
}
114+
115+
async function runWithRetry(f) {
116+
const retries = 10;
117+
const maxDelay = 4000;
118+
let delay = 1000;
119+
120+
for (let i = 0; i < retries; i++) {
121+
try {
122+
await f();
123+
break;
124+
} catch (e) {
125+
if (i === retries - 1)
126+
throw e;
127+
128+
core.error(e);
129+
const currentDelay = Math.round(Math.random() * delay);
130+
core.info(`sleeping ${currentDelay} ms`);
131+
await sleep(currentDelay);
132+
delay = Math.min(delay * 2, maxDelay);
133+
}
134+
}
135+
}
136+
137+
async function run() {
138+
await runWithRetry(runOnce);
139+
}
140+
141+
run().catch(err => {
142+
core.error(err);
143+
core.setFailed(err.message);
144+
});
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"name": "wasmtime-github-release",
3+
"version": "0.0.0",
4+
"main": "main.js",
5+
"dependencies": {
6+
"@actions/core": "^1.6",
7+
"@actions/github": "^5.0",
8+
"glob": "^7.1.5"
9+
}
10+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"problemMatcher": [
3+
{
4+
"owner": "rustfmt",
5+
"severity": "warning",
6+
"pattern": [
7+
{
8+
"regexp": "^(Diff in (.+)) at line (\\d+):$",
9+
"message": 1,
10+
"file": 2,
11+
"line": 3
12+
}
13+
]
14+
},
15+
{
16+
"owner": "clippy",
17+
"pattern": [
18+
{
19+
"regexp": "^(?:\\x1b\\[[\\d;]+m)*(warning|warn|error)(?:\\x1b\\[[\\d;]+m)*(\\[(.*)\\])?(?:\\x1b\\[[\\d;]+m)*:(?:\\x1b\\[[\\d;]+m)* ([^\\x1b]*)(?:\\x1b\\[[\\d;]+m)*$",
20+
"severity": 1,
21+
"message": 4,
22+
"code": 3
23+
},
24+
{
25+
"regexp": "^(?:\\x1b\\[[\\d;]+m)*\\s*(?:\\x1b\\[[\\d;]+m)*\\s*--> (?:\\x1b\\[[\\d;]+m)*(.*):(\\d*):(\\d*)(?:\\x1b\\[[\\d;]+m)*$",
26+
"file": 1,
27+
"line": 2,
28+
"column": 3
29+
}
30+
]
31+
}
32+
]
33+
}

0 commit comments

Comments
 (0)