Skip to content
This repository has been archived by the owner on Oct 13, 2023. It is now read-only.

Commit

Permalink
Fix the broken downloading (hopefully)
Browse files Browse the repository at this point in the history
  • Loading branch information
xd009642 committed Feb 4, 2023
1 parent 044a1e5 commit 9bc7570
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ jobs:
uses: actions-rs/[email protected]
with:
version: '0.15.0'
target: 'x86_64-unknown-linux-gnu'
args: '-- --test-threads 1'

- name: Upload to codecov.io
Expand All @@ -52,6 +53,7 @@ See [additional recipes here](https://github.com/actions-rs/meta).
| Name | Required | Description | Type | Default |
| ------------| :------: | ---------------------------------------------------------------------------------------------------------| ------ | --------|
| `version` | | The version of `cargo-tarpaulin` that will be installed. | string | latest |
| `target` | ✓ | The target to install tarpaulin for i.e. `x86_64-unknown-linux-gnu`. | string | latest |
| `run-types` | | The type of tests to run (`Tests`, or `Doctests`). Runs all by default. May be overridden by `args`. | string | |
| `timeout` | | The timeout, in seconds, before cancelling execution of a long running test. May be overriden by `args`. | string | |
| `args` | | Extra command line arguments that are passed to `cargo-tarpaulin`. | string | |
Expand Down
7 changes: 6 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,19 @@ branding:
color: black

runs:
using: 'node12'
using: 'node16'
main: 'dist/index.js'

inputs:
version:
description: 'The version of cargo-tarpaulin to install'
required: true
default: 'latest'

target:
description: 'The target to install for cargo-tarpaulin'
required: true
default: 'latest'

args:
required: false
Expand Down
3 changes: 3 additions & 0 deletions src/args.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { OutputType } from './config';

export interface ActionInputs {
requestedVersion: string,
target: String,
timeout: string,
runType: string,
opts: string | null,
Expand All @@ -11,13 +12,15 @@ export interface ActionInputs {

export default function getActionInputs(): ActionInputs {
const requestedVersion = input.getInput('version');
const target = input.getInput('target');
const runType = input.getInput('run-types');
const timeout = input.getInput('timeout');
const opts = input.getInput('args');
const outType = input.getInput('out-type') as OutputType;

return {
requestedVersion,
target,
runType,
timeout,
opts,
Expand Down
11 changes: 6 additions & 5 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export default async function resolveConfig(input: ActionInputs): Promise<Tarpau
releaseEndpoint = process.env.GITHUB_RELEASE_ENDPOINT;
}

const downloadUrl = await getDownloadUrl(releaseEndpoint, input.requestedVersion);
const downloadUrl = await getDownloadUrl(releaseEndpoint, input.target, input.requestedVersion);
const type = input.runType ? input.runType : null;
const timeout = input.timeout ? input.timeout : null;
const outType = input.outType ? input.outType : "Xml";
Expand All @@ -71,19 +71,20 @@ export default async function resolveConfig(input: ActionInputs): Promise<Tarpau
* @param requestedVersion The Git tag of the tarpaulin revision to get a download URL for. May be any valid Git tag,
* or a special-cased `latest`.
*/
async function getDownloadUrl(releaseEndpoint: string, requestedVersion: string): Promise<string> {
async function getDownloadUrl(releaseEndpoint: string, target: String, requestedVersion: string): Promise<string> {
const releaseInfoUri = requestedVersion === 'latest' ?
`${releaseEndpoint}/latest` :
`${releaseEndpoint}/tags/${requestedVersion}`;

const releaseInfoRequest = await fetch(releaseInfoUri);
const releaseInfo = await releaseInfoRequest.json();
const asset = releaseInfo["assets"].find(asset => {
return asset['content_type'] === 'application/gzip';

const asset = releaseInfo["name"].find(asset => {
return asset['name'].startsWith(`cargo-tarpaulin-${target}`)
});

if (!asset) {
throw new Error(`Couldn't find a release tarball containing binaries for ${requestedVersion}`);
throw new Error(`Couldn't find ${requestedVersion} release tarball containing ${target} binaries`);
}

return asset["browser_download_url"];
Expand Down

0 comments on commit 9bc7570

Please sign in to comment.