Skip to content

Commit c04a138

Browse files
committed
Merge branch 'master' into v1
2 parents 9b54957 + ad5d4ad commit c04a138

File tree

2,695 files changed

+480
-471354
lines changed

Some content is hidden

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

2,695 files changed

+480
-471354
lines changed

.github/test/crystal-libs_spec.cr

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
require "spec"
2+
require "yaml"
3+
4+
it "yaml" do
5+
any = YAML::Any.new({
6+
YAML::Any.new("foo") => YAML::Any.new(12_i64)
7+
})
8+
YAML.parse(any.to_yaml).should eq any
9+
end
10+
11+
require "xml"
12+
13+
it "xml" do
14+
string = XML.build do |xml|
15+
xml.element("person", id: 1) do
16+
xml.element("firstname") { xml.text "Jane" }
17+
xml.element("lastname") { xml.text "Doe" }
18+
end
19+
end
20+
21+
document = XML.parse(string)
22+
person = document.first_element_child.should_not be_nil
23+
person["id"].should eq "1"
24+
25+
props = {} of String => String
26+
person.children.select(&.element?).each do |child|
27+
props[child.name] = child.content
28+
end
29+
props.should eq({
30+
"firstname" => "Jane",
31+
"lastname" => "Doe",
32+
})
33+
end
34+
35+
require "big"
36+
37+
it "big" do
38+
1.to_big_d.to_i.should eq 1
39+
end
40+
41+
require "openssl/sha1"
42+
43+
it "openssl" do
44+
OpenSSL::SHA1.hash("foobarbaz").should eq StaticArray[95, 85, 19, 248, 130, 47, 219, 229, 20, 90, 243, 59, 100, 216, 217, 112, 220, 249, 92, 110]
45+
end

.github/workflows/deploy-docs.yml

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,10 @@ on:
99
- cron: '0 6 * * 6'
1010
jobs:
1111
build:
12-
name: Deploy docs
1312
runs-on: ubuntu-latest
1413
steps:
1514
- name: Download source
16-
uses: actions/checkout@v3
15+
uses: actions/checkout@v4
1716
- name: Install Python
1817
uses: actions/setup-python@v4
1918
with:
@@ -25,9 +24,21 @@ jobs:
2524
- name: Build site
2625
run: mkdocs build
2726
working-directory: docs
28-
- name: Deploy to gh-pages
29-
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
30-
uses: oprypin/push-to-gh-pages@v3
27+
- name: Upload to GitHub Pages
28+
uses: actions/upload-pages-artifact@v2
3129
with:
32-
publish_dir: site
33-
commit_message: 'Generate docs: '
30+
path: site
31+
deploy:
32+
if: github.event_name == 'push' && github.ref_name == github.event.repository.default_branch
33+
needs: build
34+
permissions:
35+
pages: write
36+
id-token: write
37+
runs-on: ubuntu-latest
38+
steps:
39+
- name: Deploy to GitHub Pages
40+
id: deployment
41+
uses: actions/deploy-pages@v2
42+
environment:
43+
name: github-pages
44+
url: ${{ steps.deployment.outputs.page_url }}

.github/workflows/main.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ jobs:
2323
- {shards: '0.14', crystal: '1.3'}
2424
- {shards: latest, crystal: latest}
2525
- {shards: nightly, crystal: nightly}
26+
- {crystal: 'branch:master'}
2627
exclude:
2728
- os: windows-latest
2829
config: {shards: '0.12.0', crystal: '0.35.1'}
@@ -55,10 +56,9 @@ jobs:
5556
- run: |
5657
v='${{ matrix.config.crystal }}'
5758
crystal --version | grep -E "${v}\\b"
58-
if: ${{ contains(matrix.config.crystal, '.') }}
59+
if: ${{ contains(matrix.config.crystal, '.') && !contains(matrix.config.crystal, 'branch:') }}
5960
- run: |
60-
crystal eval 'require "yaml"; require "xml"; require "big"; require "openssl"'
61-
61+
crystal spec .github/test/crystal-libs_spec.cr
6262
- run: |
6363
shards --version
6464
if: ${{ !contains('false', matrix.config.shards) }}
@@ -82,7 +82,6 @@ jobs:
8282
test:
8383
runs-on: ubuntu-latest
8484
steps:
85-
- uses: actions/checkout@v3
85+
- uses: actions/checkout@v4
8686
- run: npm install
8787
- run: npm test
88-
- run: npm audit --audit-level=moderate --only=prod

.github/workflows/release.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ jobs:
2323
- {shards: '0.14', crystal: '1.3'}
2424
- {shards: latest, crystal: latest}
2525
- {shards: nightly, crystal: nightly}
26+
- {crystal: 'branch:master'}
2627
exclude:
2728
- os: windows-latest
2829
config: {shards: '0.12.0', crystal: '0.35.1'}
@@ -33,7 +34,7 @@ jobs:
3334
run:
3435
shell: bash
3536
steps:
36-
- uses: actions/checkout@v3
37+
- uses: actions/checkout@v4
3738

3839
- uses: crystal-lang/install-crystal@v1
3940
with: ${{ matrix.config }}
@@ -55,10 +56,9 @@ jobs:
5556
- run: |
5657
v='${{ matrix.config.crystal }}'
5758
crystal --version | grep -E "${v}\\b"
58-
if: ${{ contains(matrix.config.crystal, '.') }}
59+
if: ${{ contains(matrix.config.crystal, '.') && !contains(matrix.config.crystal, 'branch:') }}
5960
- run: |
60-
crystal eval 'require "yaml"; require "xml"; require "big"; require "openssl"'
61-
61+
crystal spec .github/test/crystal-libs_spec.cr
6262
- run: |
6363
shards --version
6464
if: ${{ !contains('false', matrix.config.shards) }}

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ Alternatively, you can use the container-based approach [as in the starter workf
6868

6969
Install Crystal from the latest continuous build on [crystal.git][] master.
7070

71+
* **`crystal: "branch:foo/bar"`**
72+
73+
Install Crystal from the latest maintenance build on [crystal.git][] branch specified after `branch:`.
74+
7175
* * **`shards: true`** (default)
7276

7377
Ensure that *some* released version of [Shards][] is available.

action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ outputs:
2222
path:
2323
description: The directory where Crystal was installed
2424
runs:
25-
using: node16
25+
using: node20
2626
main: index.js
2727
branding:
2828
icon: octagon

docs/requirements.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,17 @@ mkdocs-gen-files==0.4.0
3939
# via -r requirements.in
4040
mkdocs-macros-plugin==0.7.0
4141
# via -r requirements.in
42-
mkdocs-material==8.5.10
42+
mkdocs-material==8.5.11
4343
# via -r requirements.in
44-
mkdocs-material-extensions==1.1
44+
mkdocs-material-extensions==1.1.1
4545
# via mkdocs-material
4646
mkdocs-same-dir==0.1.2
4747
# via -r requirements.in
4848
packaging==21.3
4949
# via mkdocs
5050
pygments==2.13.0
5151
# via mkdocs-material
52-
pymdown-extensions==9.8
52+
pymdown-extensions==9.9
5353
# via
5454
# -r requirements.in
5555
# mkdocs-material
@@ -70,9 +70,9 @@ requests==2.28.1
7070
# via mkdocs-material
7171
six==1.16.0
7272
# via python-dateutil
73-
termcolor==2.1.0
73+
termcolor==2.1.1
7474
# via mkdocs-macros-plugin
75-
urllib3==1.26.12
75+
urllib3==1.26.13
7676
# via requests
7777
watchdog==2.1.9
7878
# via mkdocs

index.js

Lines changed: 45 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ async function run() {
3333
params.shards = "nightly";
3434
}
3535
params.path = Core.getInput("destination") || Path.join(
36-
process.env["RUNNER_TEMP"], `crystal-${params.crystal}-${params.shards}-${params.arch}`,
36+
process.env["RUNNER_TEMP"], `crystal-${params.crystal.replace("branch:", "")}-${params.shards}-${params.arch}`,
3737
);
3838
Core.setOutput("path", params.path);
3939

@@ -87,17 +87,22 @@ const Nightly = "nightly";
8787
const Any = "true";
8888
const None = "false";
8989
const NumericVersion = /^\d([.\d]*\d)?$/;
90+
const BranchVersion = /^branch:(.+)$/;
9091

9192
function checkVersion(version, allowed, earliestAllowed = null) {
9293
const numericVersion = NumericVersion.test(version) && version;
9394
if (numericVersion && (!earliestAllowed || cmpTags(numericVersion, earliestAllowed) >= 0)) {
9495
allowed[allowed.indexOf(NumericVersion)] = numericVersion;
9596
}
97+
const branchVersion = BranchVersion.test(version) && version;
98+
if (branchVersion) {
99+
allowed[allowed.indexOf(BranchVersion)] = branchVersion;
100+
}
96101

97102
if (allowed.includes(version)) {
98103
return version;
99104
}
100-
if ([Latest, Nightly, numericVersion].includes(version)) {
105+
if ([Latest, Nightly, numericVersion, branchVersion].includes(version)) {
101106
throw `Version "${version}" is not supported on ${getPlatform()}`;
102107
}
103108
throw `Version "${version}" is invalid`;
@@ -116,7 +121,7 @@ async function subprocess(command, options) {
116121
}
117122

118123
async function installCrystalForLinux({crystal, shards, arch = getArch(), path}) {
119-
checkVersion(crystal, [Latest, Nightly, NumericVersion]);
124+
checkVersion(crystal, [Latest, Nightly, NumericVersion, BranchVersion]);
120125
const filePatterns = {"x86_64": /-linux-x86_64\.tar\.gz$/, "x86": /-linux-i686\.tar\.gz$/};
121126
checkArch(arch, Object.keys(filePatterns));
122127

@@ -141,7 +146,7 @@ async function installCrystalForLinux({crystal, shards, arch = getArch(), path})
141146
}
142147

143148
async function installCrystalForMac({crystal, shards, arch = "x86_64", path}) {
144-
checkVersion(crystal, [Latest, Nightly, NumericVersion]);
149+
checkVersion(crystal, [Latest, Nightly, NumericVersion, BranchVersion]);
145150
if (crystal === Latest || crystal === Nightly || cmpTags(crystal, "1.2") >= 0) {
146151
checkArch(arch, ["universal", "x86_64", "aarch64"]);
147152
} else {
@@ -186,12 +191,17 @@ async function installAptPackages(packages) {
186191

187192
async function installBinaryRelease({crystal, filePattern, path}) {
188193
if (crystal === Nightly) {
189-
await IO.mv(await downloadCrystalNightly(filePattern), path);
194+
await IO.mv(await downloadCrystalNightly(filePattern, "master"), path);
190195
} else {
191-
if (crystal === Latest) {
192-
crystal = null;
196+
const version = BranchVersion.exec(crystal);
197+
if (version) {
198+
await IO.mv(await downloadCrystalNightly(filePattern, version[1]), path);
199+
} else {
200+
if (crystal === Latest) {
201+
crystal = null;
202+
}
203+
await IO.mv(await downloadCrystalRelease(filePattern, crystal), path);
193204
}
194-
await IO.mv(await downloadCrystalRelease(filePattern, crystal), path);
195205
}
196206
}
197207

@@ -336,7 +346,7 @@ async function downloadCrystalRelease(filePattern, version = null) {
336346
const resp = await github.request({
337347
url: asset["url"],
338348
headers: {"accept": "application/octet-stream"},
339-
request: {redirect: "manual"},
349+
request: {fetch: fetchWithManualRedirect},
340350
});
341351
const url = resp.headers["location"];
342352

@@ -365,29 +375,29 @@ async function downloadSource({name, repo, ref}) {
365375

366376
const resp = await github.rest.repos.downloadZipballArchive({
367377
...repo, ref,
368-
request: {redirect: "manual"},
378+
request: {fetch: fetchWithManualRedirect},
369379
});
370380
const url = resp.headers["location"];
371381
const downloadedPath = await ToolCache.downloadTool(url);
372382
Core.info(`Extracting ${name} source`);
373383
return onlySubdir(await ToolCache.extractZip(downloadedPath));
374384
}
375385

376-
async function downloadCrystalNightly(filePattern) {
377-
Core.info("Looking for latest Crystal build");
386+
async function downloadCrystalNightly(filePattern, branch) {
387+
Core.info(`Looking for latest Crystal build of branch '${branch}'`);
378388

379389
let build;
380390
for (let offset = 0; ;) {
381-
const req = `/tree/master?filter=successful&shallow=true&limit=100&offset=${offset}`;
391+
const req = `/tree/${branch}?filter=successful&shallow=true&limit=100&offset=${offset}`;
382392
const resp = await fetch(CircleApiBase + req);
383393
const builds = await resp.json();
384394
build = builds.find((b) => b["workflows"]["job_name"] === "dist_artifacts");
385395
if (build) {
386396
break;
387397
}
388398
offset += builds.length;
389-
if (offset >= 1000) {
390-
throw "Could not find a matching nightly build";
399+
if (offset >= 1000 || builds.length === 0) {
400+
throw `Could not find a matching build for branch '${branch}'`;
391401
}
392402
}
393403
Core.info(`Found Crystal build ${build["build_url"]}`);
@@ -397,6 +407,9 @@ async function downloadCrystalNightly(filePattern) {
397407
const resp = await fetch(CircleApiBase + req);
398408
const artifacts = await resp.json();
399409
const artifact = artifacts.find((a) => filePattern.test(a["path"]));
410+
if (artifact === undefined) {
411+
throw `Could not find build artifacts for build ${build["build_num"]}`;
412+
}
400413

401414
Core.info(`Downloading Crystal build from ${artifact["url"]}`);
402415
const downloadedPath = await ToolCache.downloadTool(artifact["url"]);
@@ -406,14 +419,19 @@ async function downloadCrystalNightly(filePattern) {
406419
}
407420

408421
async function installCrystalForWindows({crystal, shards, arch = "x86_64", path}) {
409-
checkVersion(crystal, [Latest, Nightly, NumericVersion], "1.3");
422+
checkVersion(crystal, [Latest, Nightly, NumericVersion, BranchVersion], "1.3");
410423
checkArch(arch, ["x86_64"]);
411424

412425
if (crystal === Nightly) {
413-
await IO.mv(await downloadCrystalNightlyForWindows(), path);
426+
await IO.mv(await downloadCrystalNightlyForWindows("master"), path);
414427
} else {
415-
const filePattern = /-windows-x86_64-msvc(-unsupported)?\.zip$/;
416-
await installBinaryRelease({crystal, shards, filePattern, path});
428+
const version = BranchVersion.exec(crystal);
429+
if (version) {
430+
await IO.mv(await downloadCrystalNightlyForWindows(version[1]), path);
431+
} else {
432+
const filePattern = /-windows-x86_64-msvc(-unsupported)?\.zip$/;
433+
await installBinaryRelease({crystal, shards, filePattern, path});
434+
}
417435
}
418436

419437
Core.info("Setting up environment for Crystal");
@@ -425,11 +443,11 @@ async function installCrystalForWindows({crystal, shards, arch = "x86_64", path}
425443
}
426444
}
427445

428-
async function downloadCrystalNightlyForWindows() {
429-
Core.info("Looking for latest Crystal build");
446+
async function downloadCrystalNightlyForWindows(branch) {
447+
Core.info(`Looking for latest Crystal build of branch '${branch}'`);
430448

431449
const runsResp = await github.rest.actions.listWorkflowRuns({
432-
...RepoCrystal, "workflow_id": "win.yml", "branch": "master",
450+
...RepoCrystal, "workflow_id": "win.yml", "branch": branch,
433451
"event": "push", "status": "success", "per_page": 1,
434452
});
435453
const [workflowRun] = runsResp.data["workflow_runs"];
@@ -445,7 +463,7 @@ async function downloadCrystalNightlyForWindows() {
445463
Core.info("Downloading Crystal build");
446464
const resp = await github.rest.actions.downloadArtifact({
447465
...RepoCrystal, "artifact_id": artifact.id, "archive_format": "zip",
448-
request: {redirect: "manual"},
466+
request: {fetch: fetchWithManualRedirect},
449467
});
450468
const url = resp.headers["location"];
451469
const downloadedPath = await ToolCache.downloadTool(url);
@@ -456,6 +474,10 @@ async function downloadCrystalNightlyForWindows() {
456474

457475
const github = new Octokit({auth: Core.getInput("token") || null});
458476

477+
function fetchWithManualRedirect(url, options) {
478+
return fetch(url, {...options, redirect: "manual"});
479+
}
480+
459481
async function* getItemsFromPages(pages) {
460482
for await (const page of github.paginate.iterator(pages)) {
461483
for (const item of page.data) {

node_modules/.bin/semver

Lines changed: 0 additions & 1 deletion
This file was deleted.

node_modules/.bin/uuid

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)