Merge pull request #30 from kachick/pr-gh-api-late-limit
Fix flaky behavior when using matrix run
This commit is contained in:
commit
a00a4c35aa
5 changed files with 38 additions and 53 deletions
18
.github/workflows/test.yml
vendored
18
.github/workflows/test.yml
vendored
|
@ -16,13 +16,25 @@ jobs:
|
|||
- run: |
|
||||
npm run all
|
||||
test: # make sure the action works on a clean machine without building
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os:
|
||||
- ubuntu-latest
|
||||
- macos-latest
|
||||
tool_versions:
|
||||
- |
|
||||
nodejs 18
|
||||
- |
|
||||
nodejs 16
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: ./
|
||||
with:
|
||||
tool_versions: |
|
||||
nodejs 18
|
||||
tool_versions: ${{ matrix.tool_versions }}
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
- run: rtx --version
|
||||
- run: rtx exec -- node --version
|
||||
- run: which node
|
||||
|
|
|
@ -19,12 +19,16 @@ jobs:
|
|||
with:
|
||||
tool_versions: |
|
||||
shellcheck 0.9.0
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
- run: shellcheck scripts/*.sh
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: jdxcode/rtx-action@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
# .tool-versions will be read from repo root
|
||||
- run: node ./my_app.js
|
||||
```
|
||||
|
|
27
dist/index.js
generated
vendored
27
dist/index.js
generated
vendored
|
@ -55,29 +55,20 @@ function run() {
|
|||
});
|
||||
}
|
||||
exports.run = run;
|
||||
function getLatestRTXAssetURL() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const output = yield exec.getExecOutput('curl', ['-sSf', 'https://api.github.com/repos/jdxcode/rtx/releases/latest'], { silent: true });
|
||||
const json = JSON.parse(output.stdout);
|
||||
const platform = `${getOS()}-${os.arch()}`;
|
||||
const asset = json.assets.find(a => a.name.endsWith(platform));
|
||||
if (!asset) {
|
||||
const assets = json.assets.map(a => a.name).join(', ');
|
||||
throw new Error(`No asset for ${platform}, got: ${assets}`);
|
||||
}
|
||||
return asset.browser_download_url;
|
||||
});
|
||||
}
|
||||
function setupRTX() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const rtxBinDir = path.join(os.homedir(), '.local/share/rtx/bin');
|
||||
const platform = `${getOS()}-${os.arch()}`;
|
||||
yield fs.promises.mkdir(rtxBinDir, { recursive: true });
|
||||
yield exec.exec('curl', [
|
||||
'-sSfL',
|
||||
'--compressed',
|
||||
yield exec.exec('gh', [
|
||||
'release',
|
||||
'download',
|
||||
'--pattern',
|
||||
`*${platform}`,
|
||||
'--repo',
|
||||
'jdxcode/rtx',
|
||||
'--output',
|
||||
path.join(rtxBinDir, 'rtx'),
|
||||
yield getLatestRTXAssetURL()
|
||||
path.join(rtxBinDir, 'rtx')
|
||||
]);
|
||||
yield exec.exec('chmod', ['+x', path.join(rtxBinDir, 'rtx')]);
|
||||
core.addPath(rtxBinDir);
|
||||
|
|
2
dist/index.js.map
generated
vendored
2
dist/index.js.map
generated
vendored
File diff suppressed because one or more lines are too long
40
src/main.ts
40
src/main.ts
|
@ -12,41 +12,19 @@ async function run(): Promise<void> {
|
|||
await setPaths()
|
||||
}
|
||||
|
||||
interface GHAsset {
|
||||
name: string
|
||||
url: string
|
||||
browser_download_url: string
|
||||
}
|
||||
|
||||
interface GHAssets {
|
||||
assets: GHAsset[]
|
||||
}
|
||||
|
||||
async function getLatestRTXAssetURL(): Promise<string> {
|
||||
const output = await exec.getExecOutput(
|
||||
'curl',
|
||||
['-sSf', 'https://api.github.com/repos/jdxcode/rtx/releases/latest'],
|
||||
{silent: true}
|
||||
)
|
||||
const json: GHAssets = JSON.parse(output.stdout)
|
||||
const platform = `${getOS()}-${os.arch()}`
|
||||
const asset = json.assets.find(a => a.name.endsWith(platform))
|
||||
if (!asset) {
|
||||
const assets = json.assets.map(a => a.name).join(', ')
|
||||
throw new Error(`No asset for ${platform}, got: ${assets}`)
|
||||
}
|
||||
return asset.browser_download_url
|
||||
}
|
||||
|
||||
async function setupRTX(): Promise<void> {
|
||||
const rtxBinDir = path.join(os.homedir(), '.local/share/rtx/bin')
|
||||
const platform = `${getOS()}-${os.arch()}`
|
||||
await fs.promises.mkdir(rtxBinDir, {recursive: true})
|
||||
await exec.exec('curl', [
|
||||
'-sSfL',
|
||||
'--compressed',
|
||||
await exec.exec('gh', [
|
||||
'release',
|
||||
'download',
|
||||
'--pattern',
|
||||
`*${platform}`,
|
||||
'--repo',
|
||||
'jdxcode/rtx',
|
||||
'--output',
|
||||
path.join(rtxBinDir, 'rtx'),
|
||||
await getLatestRTXAssetURL()
|
||||
path.join(rtxBinDir, 'rtx')
|
||||
])
|
||||
await exec.exec('chmod', ['+x', path.join(rtxBinDir, 'rtx')])
|
||||
core.addPath(rtxBinDir)
|
||||
|
|
Loading…
Add table
Reference in a new issue