Skip to content

Commit

Permalink
Fix No assets found in release error (#722)
Browse files Browse the repository at this point in the history
* Debug tar|zip only download

* Add a failing test

* Fix no assets found error

* Update CI test script

* remove default filename

* Replace regex based file matching with minimatch lib
  • Loading branch information
robinraju authored Apr 24, 2024
1 parent 62178ff commit cb096d8
Show file tree
Hide file tree
Showing 11 changed files with 2,514 additions and 109 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,19 @@ jobs:
shell: bash
run: ls -lrth test-downloads

- name: Download tarBall & zipBall only
uses: ./
with:
repository: "robinraju/probable-potato"
tag: "1.0.2"
tarBall: true
zipBall: true
out-file-path: "./public-download"

- name: List downloaded files
shell: bash
run: ls -lrth public-download

- name: Test download latest pre-release
uses: ./
with:
Expand Down
40 changes: 40 additions & 0 deletions __tests__/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,28 @@ beforeEach(() => {
nock("https://api.github.com/")
.get("/repos/foo/slick-pg/releases")
.reply(200, readFromFile("5-without-prerelease.json"))

nock("https://api.github.com")
.get("/repos/robinraju/tar-zip-ball-only-repo/releases/latest")
.reply(200, readFromFile("6-tar-zip-ball-only-repo.json"))

nock("https://api.github.com", {
reqheaders: {accept: "*/*"}
})
.get("/repos/robinraju/tar-zip-ball-only-repo/tarball/1.0.0")
.replyWithFile(
200,
__dirname + "/resource/assets/tar-zip-ball-only-repo.tar.gz"
)

nock("https://api.github.com", {
reqheaders: {accept: "*/*"}
})
.get("/repos/robinraju/tar-zip-ball-only-repo/zipball/1.0.0")
.replyWithFile(
200,
__dirname + "/resource/assets/tar-zip-ball-only-repo.zip"
)
})

afterEach(async () => {
Expand Down Expand Up @@ -384,3 +406,21 @@ test("Fail when a release with no prerelease is obtained", async () => {
const result = downloader.download(downloadSettings)
await expect(result).rejects.toThrow("No prereleases found!")
}, 10000)

test("Download from a release containing only tarBall & zipBall", async () => {
const downloadSettings: IReleaseDownloadSettings = {
sourceRepoPath: "robinraju/tar-zip-ball-only-repo",
isLatest: true,
preRelease: false,
tag: "",
id: "",
fileName: "",
tarBall: true,
zipBall: true,
extractAssets: false,
outFilePath: outputFilePath
}

const result = await downloader.download(downloadSettings)
expect(result.length).toBe(2)
})
20 changes: 20 additions & 0 deletions __tests__/resource/6-tar-zip-ball-only-repo.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"url": "https://api.github.com/repos/robinraju/tar-zip-ball-only-repo/releases/68092192",
"assets_url": "https://api.github.com/repos/robinraju/tar-zip-ball-only-repo/releases/68092192/assets",
"upload_url": "https://uploads.github.com/repos/robinraju/tar-zip-ball-only-repo/releases/68092192/assets{?name,label}",
"html_url": "https://github.com/robinraju/tar-zip-ball-only-repo/releases/tag/1.0.0",
"id": 68092192,
"author": {},
"node_id": "RE_kwDOHahpL84EDwEf",
"tag_name": "1.0.0",
"target_commitish": "main",
"name": "Release 1.0.0",
"draft": false,
"prerelease": false,
"created_at": "2024-04-24T12:03:47Z",
"published_at": "2024-04-24T12:04:42Z",
"assets": [],
"tarball_url": "https://api.github.com/repos/robinraju/tar-zip-ball-only-repo/tarball/1.0.0",
"zipball_url": "https://api.github.com/repos/robinraju/tar-zip-ball-only-repo/zipball/1.0.0",
"body": ""
}
Binary file not shown.
Binary file added __tests__/resource/assets/tar-zip-ball-only-repo.zip
Binary file not shown.
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ inputs:
required: false
fileName:
description: "Name of the file to download (use '*' to download all assets other than tarball or zipball)"
default: "*"
default: ""
required: false
tarBall:
description: "Download tarball from assets"
Expand Down
Loading

0 comments on commit cb096d8

Please # to comment.