Skip to content

Commit 22f8fb2

Browse files
authored
Merge pull request #229 from dscho/support-msys
Support MSYS mode
2 parents 95dc943 + 4057a0b commit 22f8fb2

File tree

10 files changed

+60
-40
lines changed

10 files changed

+60
-40
lines changed

.eslintrc.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
},
1010
"rules": {
1111
"eslint-comments/no-use": "off",
12+
"filenames/match-regex": [2, "^[a-z_]+(\\.test)?$", true],
1213
"import/no-namespace": "off",
1314
"no-unused-vars": "off",
1415
"@typescript-eslint/no-unused-vars": "off",

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
shell: bash
2222
run: |
2323
# `ncc` produces output with mixed line endings
24-
test -z "$(git diff -aw HEAD | tee diff.txt)" || {
24+
test -z "$(git diff -aw HEAD -- ':(exclude)dist/index.js.map' | tee diff.txt)" || {
2525
echo 'Files changed after `npm run package`'
2626
cat diff.txt
2727
exit 1

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ By default, this Action prints a line whenever 250 items were extracted (this do
7070

7171
To accelerate this Action, artifacts are cached once downloaded. This can be turned off by setting the input parameter `cache` to `false`.
7272

73-
In practice, caching the `full` artifacts does not provide much of a speed-up. Instead, it slows it down by adding several minutes during with the artifact is cached. Therefore, caching is disabled for the `full` artifacts by default, corresponding to `cache: auto`.
73+
In practice, caching the `full` artifacts does not provide much of a speed-up. Instead, it slows it down by spending extra minutes on caching the artifact. Therefore, caching is disabled for the `full` artifacts by default, corresponding to `cache: auto`.
7474

7575
## Developing _this_ Action
7676

__tests__/downloader.test.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
import fetch from 'node-fetch'
12
import {get} from '../src/downloader'
23
import {mocked} from 'ts-jest/utils'
3-
import fetch from 'node-fetch'
44

55
const buildIdResponse = {
66
count: 1,
@@ -19,8 +19,7 @@ const buildIdResponse = {
1919
queueTime: '2021-02-16T03:11:20.8026424Z',
2020
startTime: '2021-02-16T03:11:35.5385517Z',
2121
finishTime: '2021-02-16T03:42:07.4413436Z',
22-
url:
23-
'https://dev.azure.com/Git-for-Windows/f3317b6a-fa67-40d4-9a33-b652e06943df/_apis/build/Builds/71000',
22+
url: 'https://dev.azure.com/Git-for-Windows/f3317b6a-fa67-40d4-9a33-b652e06943df/_apis/build/Builds/71000',
2423
definition: [Object],
2524
project: [Object],
2625
uri: 'vstfs:///Build/Build/71000',

__tests__/main.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/* eslint-disable no-console */
2-
import {statSync} from 'fs'
3-
import * as process from 'process'
42
import * as child_process from 'child_process'
53
import * as path from 'path'
4+
import * as process from 'process'
5+
import {statSync} from 'fs'
66

77
async function runAction(
88
options?: child_process.SpawnOptionsWithoutStdio

action.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ inputs:
1313
required: false
1414
description: 'The architecture of the SDK: x86_64 or i686'
1515
default: 'x86_64'
16+
msys:
17+
required: false
18+
description: 'Whether to start in MSYS mode (defaults to false)'
19+
default: 'false'
1620
path:
1721
required: false
1822
description: 'Where to write the SDK files'

dist/index.js

Lines changed: 27 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

main.ts

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as core from '@actions/core'
2-
import process from 'process'
3-
import {get} from './src/downloader'
42
import {restoreCache, saveCache} from '@actions/cache'
3+
import {get} from './src/downloader'
4+
import process from 'process'
55

66
async function run(): Promise<void> {
77
try {
@@ -14,6 +14,7 @@ async function run(): Promise<void> {
1414
const flavor = core.getInput('flavor')
1515
const architecture = core.getInput('architecture')
1616
const verbose = core.getInput('verbose')
17+
const msysMode = core.getInput('msys') === 'true'
1718

1819
const {artifactName, download, id} = await get(flavor, architecture)
1920
const outputDirectory = core.getInput('path') || `C:/${artifactName}`
@@ -58,11 +59,19 @@ async function run(): Promise<void> {
5859
}
5960
}
6061

61-
// Set up PATH so that Git for Windows' SDK's `bash.exe`, `prove` and `gcc` are found
62-
core.addPath(`${outputDirectory}/usr/bin/core_perl`)
63-
core.addPath(`${outputDirectory}/usr/bin`)
64-
const msystem = architecture === 'i686' ? 'MINGW32' : 'MINGW64'
65-
core.addPath(`${outputDirectory}/${msystem.toLocaleLowerCase()}/bin`)
62+
const mingw = architecture === 'i686' ? 'MINGW32' : 'MINGW64'
63+
const msystem = msysMode ? 'MSYS' : mingw
64+
65+
const binPaths = [
66+
// Set up PATH so that Git for Windows' SDK's `bash.exe`, `prove` and `gcc` are found
67+
'/usr/bin/core_perl',
68+
'/usr/bin',
69+
`/${mingw.toLocaleLowerCase()}/bin`
70+
]
71+
for (const binPath of msysMode ? binPaths.reverse() : binPaths) {
72+
core.addPath(`${outputDirectory}${binPath}`)
73+
}
74+
6675
core.exportVariable('MSYSTEM', msystem)
6776
if (
6877
!('LANG' in process.env) &&

src/downloader.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import fs from 'fs'
2-
import https from 'https'
31
import {Readable} from 'stream'
4-
import unzipper from 'unzipper'
5-
import {spawn} from 'child_process'
62
import {delimiter} from 'path'
73
import fetch from '@adobe/node-fetch-retry'
4+
import fs from 'fs'
5+
import https from 'https'
6+
import {spawn} from 'child_process'
7+
import unzipper from 'unzipper'
88

99
const gitForWindowsUsrBinPath = 'C:/Program Files/Git/usr/bin'
1010
const gitForWindowsMINGW64BinPath = 'C:/Program Files/Git/mingw64/bin'
@@ -27,7 +27,7 @@ function mkdirp(directoryPath: string): void {
2727
}
2828
throw new Error(`${directoryPath} exists, but is not a directory`)
2929
} catch (e) {
30-
if (!(e instanceof Object) || (e as any).code !== 'ENOENT') {
30+
if (!(e instanceof Object) || (e as {code: string}).code !== 'ENOENT') {
3131
throw e
3232
}
3333
}

0 commit comments

Comments
 (0)