Skip to content

Commit

Permalink
foo
Browse files Browse the repository at this point in the history
  • Loading branch information
p0deje committed Jun 10, 2024
1 parent 330cba8 commit 273e977
Show file tree
Hide file tree
Showing 6 changed files with 166 additions and 80 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,10 @@ Default `false`.
```
</details>

## Note for Windows ARM64 Users

When using this action on Windows ARM64 architecture, the setup will temporarily use the x64 version of Bazelisk due to the current unavailability of a native ARM64 binary. This is a temporary workaround until an ARM64 binary becomes available. For more details, see [bazelbuild/bazelisk#572](https://github.com/bazelbuild/bazelisk/issues/572).

## Migrating from [`bazelbuild/setup-bazelisk`][6]

You can simply replace `bazelbuild/setup-bazelisk` action with `bazel-contrib/setup-bazel`.
Expand Down
119 changes: 80 additions & 39 deletions dist/main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -88486,6 +88486,7 @@ function composeDoc(options, directives, { offset, start, value, end }, onError)
next: value ?? end?.[0],
offset,
onError,
parentIndent: 0,
startOnNewline: true
});
if (props.found) {
Expand Down Expand Up @@ -88628,7 +88629,7 @@ var resolveFlowScalar = __nccwpck_require__(261);

function composeScalar(ctx, token, tagToken, onError) {
const { value, type, comment, range } = token.type === 'block-scalar'
? resolveBlockScalar.resolveBlockScalar(token, ctx.options.strict, onError)
? resolveBlockScalar.resolveBlockScalar(ctx, token, onError)
: resolveFlowScalar.resolveFlowScalar(token, ctx.options.strict, onError);
const tagName = tagToken
? ctx.directives.tagName(tagToken.source, msg => onError(tagToken, 'TAG_RESOLVE_FAILED', msg))
Expand Down Expand Up @@ -88963,6 +88964,7 @@ function resolveBlockMap({ composeNode, composeEmptyNode }, ctx, bm, onError, ta
next: key ?? sep?.[0],
offset,
onError,
parentIndent: bm.indent,
startOnNewline: true
});
const implicitKey = !keyProps.found;
Expand Down Expand Up @@ -89005,6 +89007,7 @@ function resolveBlockMap({ composeNode, composeEmptyNode }, ctx, bm, onError, ta
next: value,
offset: keyNode.range[2],
onError,
parentIndent: bm.indent,
startOnNewline: !key || key.type === 'block-scalar'
});
offset = valueProps.end;
Expand Down Expand Up @@ -89063,9 +89066,9 @@ exports.resolveBlockMap = resolveBlockMap;

var Scalar = __nccwpck_require__(9338);

function resolveBlockScalar(scalar, strict, onError) {
function resolveBlockScalar(ctx, scalar, onError) {
const start = scalar.offset;
const header = parseBlockScalarHeader(scalar, strict, onError);
const header = parseBlockScalarHeader(scalar, ctx.options.strict, onError);
if (!header)
return { value: '', type: null, comment: '', range: [start, start, start] };
const type = header.mode === '>' ? Scalar.Scalar.BLOCK_FOLDED : Scalar.Scalar.BLOCK_LITERAL;
Expand Down Expand Up @@ -89107,6 +89110,10 @@ function resolveBlockScalar(scalar, strict, onError) {
if (header.indent === 0)
trimIndent = indent.length;
contentStart = i;
if (trimIndent === 0 && !ctx.atRoot) {
const message = 'Block scalar values in collections must be indented';
onError(offset, 'BAD_INDENT', message);
}
break;
}
offset += indent.length + content.length + 1;
Expand Down Expand Up @@ -89282,6 +89289,7 @@ function resolveBlockSeq({ composeNode, composeEmptyNode }, ctx, bs, onError, ta
next: value,
offset,
onError,
parentIndent: bs.indent,
startOnNewline: true
});
if (!props.found) {
Expand Down Expand Up @@ -89398,6 +89406,7 @@ function resolveFlowCollection({ composeNode, composeEmptyNode }, ctx, fc, onErr
next: key ?? sep?.[0],
offset,
onError,
parentIndent: fc.indent,
startOnNewline: false
});
if (!props.found) {
Expand Down Expand Up @@ -89479,6 +89488,7 @@ function resolveFlowCollection({ composeNode, composeEmptyNode }, ctx, fc, onErr
next: value,
offset: keyNode.range[2],
onError,
parentIndent: fc.indent,
startOnNewline: false
});
if (valueProps.found) {
Expand Down Expand Up @@ -89810,7 +89820,7 @@ exports.resolveFlowScalar = resolveFlowScalar;
"use strict";


function resolveProps(tokens, { flow, indicator, next, offset, onError, startOnNewline }) {
function resolveProps(tokens, { flow, indicator, next, offset, onError, parentIndent, startOnNewline }) {
let spaceBefore = false;
let atNewline = startOnNewline;
let hasSpace = startOnNewline;
Expand All @@ -89819,6 +89829,7 @@ function resolveProps(tokens, { flow, indicator, next, offset, onError, startOnN
let hasNewline = false;
let hasNewlineAfterProp = false;
let reqSpace = false;
let tab = null;
let anchor = null;
let tag = null;
let comma = null;
Expand All @@ -89832,16 +89843,22 @@ function resolveProps(tokens, { flow, indicator, next, offset, onError, startOnN
onError(token.offset, 'MISSING_CHAR', 'Tags and anchors must be separated from the next token by white space');
reqSpace = false;
}
if (tab) {
if (atNewline && token.type !== 'comment' && token.type !== 'newline') {
onError(tab, 'TAB_AS_INDENT', 'Tabs are not allowed as indentation');
}
tab = null;
}
switch (token.type) {
case 'space':
// At the doc level, tabs at line start may be parsed
// as leading white space rather than indentation.
// In a flow collection, only the parser handles indent.
if (!flow &&
atNewline &&
indicator !== 'doc-start' &&
token.source[0] === '\t')
onError(token, 'TAB_AS_INDENT', 'Tabs are not allowed as indentation');
(indicator !== 'doc-start' || next?.type !== 'flow-collection') &&
token.source.includes('\t')) {
tab = token;
}
hasSpace = true;
break;
case 'comment': {
Expand Down Expand Up @@ -89901,7 +89918,8 @@ function resolveProps(tokens, { flow, indicator, next, offset, onError, startOnN
if (found)
onError(token, 'UNEXPECTED_TOKEN', `Unexpected ${token.source} in ${flow ?? 'collection'}`);
found = token;
atNewline = false;
atNewline =
indicator === 'seq-item-ind' || indicator === 'explicit-key-ind';
hasSpace = false;
break;
case 'comma':
Expand All @@ -89927,8 +89945,14 @@ function resolveProps(tokens, { flow, indicator, next, offset, onError, startOnN
next.type !== 'space' &&
next.type !== 'newline' &&
next.type !== 'comma' &&
(next.type !== 'scalar' || next.source !== ''))
(next.type !== 'scalar' || next.source !== '')) {
onError(next.offset, 'MISSING_CHAR', 'Tags and anchors must be separated from the next token by white space');
}
if (tab &&
((atNewline && tab.indent <= parentIndent) ||
next?.type === 'block-map' ||
next?.type === 'block-seq'))
onError(tab, 'TAB_AS_INDENT', 'Tabs are not allowed as indentation');
return {
comma,
found,
Expand Down Expand Up @@ -91941,7 +91965,7 @@ function resolveAsScalar(token, strict = true, onError) {
case 'double-quoted-scalar':
return resolveFlowScalar.resolveFlowScalar(token, strict, _onError);
case 'block-scalar':
return resolveBlockScalar.resolveBlockScalar(token, strict, _onError);
return resolveBlockScalar.resolveBlockScalar({ options: { strict } }, token, _onError);
}
}
return null;
Expand Down Expand Up @@ -92526,11 +92550,11 @@ function isEmpty(ch) {
return false;
}
}
const hexDigits = '0123456789ABCDEFabcdef'.split('');
const tagChars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()".split('');
const invalidFlowScalarChars = ',[]{}'.split('');
const invalidAnchorChars = ' ,[]{}\n\r\t'.split('');
const isNotAnchorChar = (ch) => !ch || invalidAnchorChars.includes(ch);
const hexDigits = new Set('0123456789ABCDEFabcdef');
const tagChars = new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()");
const flowIndicatorChars = new Set(',[]{}');
const invalidAnchorChars = new Set(' ,[]{}\n\r\t');
const isNotAnchorChar = (ch) => !ch || invalidAnchorChars.has(ch);
/**
* Splits an input string into lexical tokens, i.e. smaller strings that are
* easily identifiable by `tokens.tokenType()`.
Expand Down Expand Up @@ -92972,8 +92996,10 @@ class Lexer {
if (indent >= this.indentNext) {
if (this.blockScalarIndent === -1)
this.indentNext = indent;
else
this.indentNext += this.blockScalarIndent;
else {
this.indentNext =
this.blockScalarIndent + (this.indentNext === 0 ? 1 : this.indentNext);
}
do {
const cs = this.continueScalar(nl + 1);
if (cs === -1)
Expand All @@ -92986,14 +93012,25 @@ class Lexer {
nl = this.buffer.length;
}
}
if (!this.blockScalarKeep) {
// Trailing insufficiently indented tabs are invalid.
// To catch that during parsing, we include them in the block scalar value.
let i = nl + 1;
ch = this.buffer[i];
while (ch === ' ')
ch = this.buffer[++i];
if (ch === '\t') {
while (ch === '\t' || ch === ' ' || ch === '\r' || ch === '\n')
ch = this.buffer[++i];
nl = i - 1;
}
else if (!this.blockScalarKeep) {
do {
let i = nl - 1;
let ch = this.buffer[i];
if (ch === '\r')
ch = this.buffer[--i];
const lastChar = i; // Drop the line if last char not more indented
while (ch === ' ' || ch === '\t')
while (ch === ' ')
ch = this.buffer[--i];
if (ch === '\n' && i >= this.pos && i + 1 + indent > lastChar)
nl = i;
Expand All @@ -93013,7 +93050,7 @@ class Lexer {
while ((ch = this.buffer[++i])) {
if (ch === ':') {
const next = this.buffer[i + 1];
if (isEmpty(next) || (inFlow && next === ','))
if (isEmpty(next) || (inFlow && flowIndicatorChars.has(next)))
break;
end = i;
}
Expand All @@ -93028,7 +93065,7 @@ class Lexer {
else
end = i;
}
if (next === '#' || (inFlow && invalidFlowScalarChars.includes(next)))
if (next === '#' || (inFlow && flowIndicatorChars.has(next)))
break;
if (ch === '\n') {
const cs = this.continueScalar(i + 1);
Expand All @@ -93038,7 +93075,7 @@ class Lexer {
}
}
else {
if (inFlow && invalidFlowScalarChars.includes(ch))
if (inFlow && flowIndicatorChars.has(ch))
break;
end = i;
}
Expand Down Expand Up @@ -93083,7 +93120,7 @@ class Lexer {
case ':': {
const inFlow = this.flowLevel > 0;
const ch1 = this.charAt(1);
if (isEmpty(ch1) || (inFlow && invalidFlowScalarChars.includes(ch1))) {
if (isEmpty(ch1) || (inFlow && flowIndicatorChars.has(ch1))) {
if (!inFlow)
this.indentNext = this.indentValue + 1;
else if (this.flowKey)
Expand All @@ -93108,11 +93145,11 @@ class Lexer {
let i = this.pos + 1;
let ch = this.buffer[i];
while (ch) {
if (tagChars.includes(ch))
if (tagChars.has(ch))
ch = this.buffer[++i];
else if (ch === '%' &&
hexDigits.includes(this.buffer[i + 1]) &&
hexDigits.includes(this.buffer[i + 2])) {
hexDigits.has(this.buffer[i + 1]) &&
hexDigits.has(this.buffer[i + 2])) {
ch = this.buffer[(i += 3)];
}
else
Expand Down Expand Up @@ -93520,7 +93557,7 @@ class Parser {
}
else {
Object.assign(it, { key: token, sep: [] });
this.onKeyLine = !includesToken(it.start, 'explicit-key-ind');
this.onKeyLine = !it.explicitKey;
return;
}
break;
Expand Down Expand Up @@ -93729,9 +93766,9 @@ class Parser {
return;
}
if (this.indent >= map.indent) {
const atNextItem = !this.onKeyLine &&
this.indent === map.indent &&
it.sep &&
const atMapIndent = !this.onKeyLine && this.indent === map.indent;
const atNextItem = atMapIndent &&
(it.sep || it.explicitKey) &&
this.type !== 'seq-item-ind';
// For empty nodes, assign newline-separated not indented empty tokens to following node
let start = [];
Expand Down Expand Up @@ -93772,25 +93809,26 @@ class Parser {
}
return;
case 'explicit-key-ind':
if (!it.sep && !includesToken(it.start, 'explicit-key-ind')) {
if (!it.sep && !it.explicitKey) {
it.start.push(this.sourceToken);
it.explicitKey = true;
}
else if (atNextItem || it.value) {
start.push(this.sourceToken);
map.items.push({ start });
map.items.push({ start, explicitKey: true });
}
else {
this.stack.push({
type: 'block-map',
offset: this.offset,
indent: this.indent,
items: [{ start: [this.sourceToken] }]
items: [{ start: [this.sourceToken], explicitKey: true }]
});
}
this.onKeyLine = true;
return;
case 'map-value-ind':
if (includesToken(it.start, 'explicit-key-ind')) {
if (it.explicitKey) {
if (!it.sep) {
if (includesToken(it.start, 'newline')) {
Object.assign(it, { key: null, sep: [this.sourceToken] });
Expand Down Expand Up @@ -93881,9 +93919,7 @@ class Parser {
default: {
const bv = this.startBlockValue(map);
if (bv) {
if (atNextItem &&
bv.type !== 'block-seq' &&
includesToken(it.start, 'explicit-key-ind')) {
if (atMapIndent && bv.type !== 'block-seq') {
map.items.push({ start });
}
this.stack.push(bv);
Expand Down Expand Up @@ -94104,7 +94140,7 @@ class Parser {
type: 'block-map',
offset: this.offset,
indent: this.indent,
items: [{ start }]
items: [{ start, explicitKey: true }]
};
}
case 'map-value-ind': {
Expand Down Expand Up @@ -96930,6 +96966,11 @@ async function downloadBazelisk() {
let platform = config.os.platform
if (platform == "win32") {
platform = "windows"
// Temporary workaround for ARM64 on Windows until an ARM64 binary is available.
// See https://github.com/bazelbuild/bazelisk/issues/572 for details.
if (arch == 'arm64') {
arch = 'amd64'
}
}

let filename = `bazelisk-${platform}-${arch}`
Expand Down
2 changes: 1 addition & 1 deletion dist/main/index.js.map

Large diffs are not rendered by default.

Loading

0 comments on commit 273e977

Please sign in to comment.