Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

check latest and tagged releases using releases-json #272

Merged
merged 2 commits into from
Jan 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ jobs:
uses: docker/bake-action@v2
with:
targets: test
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
-
name: Upload coverage
uses: codecov/codecov-action@v3
Expand Down
31 changes: 0 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ ___
* [Usage](#usage)
* [Customizing](#customizing)
* [inputs](#inputs)
* [Using on GHES](#using-on-ghes)
* [License](#license)

## Usage
Expand Down Expand Up @@ -64,36 +63,6 @@ Following inputs can be used as `step.with` keys
| `args` | String | | Arguments to pass to Mage |
| `workdir` | String | `.` | Working directory (below repository root) |

## Using on GHES

If you specify a version or `latest` of GoReleaser in your workflow, the
version will be downloaded from [GitHub Releases in `magefile/mage`](https://github.com/magefile/mage/releases)
repository. These calls to `magefile/mage` are made via unauthenticated
requests, which are limited to [60 requests per hour per IP](https://docs.github.com/en/rest/overview/resources-in-the-rest-api#rate-limiting).

If more requests are made within the time frame, then you will start to see
rate-limit errors during downloading that looks like:

```
##[error]API rate limit exceeded for...
```

To get a higher rate limit, you can [generate a personal access token on github.com](https://github.com/settings/tokens/new)
and pass it as the `github_token` input for the action:

```yaml
uses: magefile/mage-action@v2
with:
github_token: ${{ secrets.GH_DOTCOM_TOKEN }}
version: v1.14.0
```

If the runner is not able to access `github.com`, it will take the default one
available on the GitHub Runner or runner's tool cache. See "[Setting up the
tool cache on self-hosted runners without internet
access](https://docs.github.com/en/[email protected]/admin/github-actions/managing-access-to-actions-from-githubcom/setting-up-the-tool-cache-on-self-hosted-runners-without-internet-access)"
for more information.

## License

MIT. See `LICENSE` for more details.
22 changes: 0 additions & 22 deletions __tests__/github.test.ts

This file was deleted.

28 changes: 26 additions & 2 deletions __tests__/installer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,38 @@ import {describe, expect, it} from '@jest/globals';
import * as fs from 'fs';
import * as installer from '../src/installer';

describe('getRelease', () => {
it('returns latest Mage GitHub release', async () => {
const release = await installer.getRelease('latest');
expect(release).not.toBeNull();
expect(release?.tag_name).not.toEqual('');
});

it('returns v1.8.0 Mage GitHub release', async () => {
const release = await installer.getRelease('v1.8.0');
expect(release).not.toBeNull();
expect(release?.id).toEqual(14481575);
expect(release?.tag_name).toEqual('v1.8.0');
expect(release?.html_url).toEqual('https://github.com/magefile/mage/releases/tag/v1.8.0');
});

it('unknown release', async () => {
await expect(installer.getRelease('foo')).rejects.toThrowError(
new Error(
'Cannot find Mage release foo in https://raw.githubusercontent.com/magefile/mage-action/master/.github/mage-releases.json'
)
);
});
});

describe('installer', () => {
it('acquires v1.8.0 version of Mage', async () => {
const mage = await installer.getMage('v1.8.0', process.env.GITHUB_TOKEN || '');
const mage = await installer.getMage('v1.8.0');
expect(fs.existsSync(mage)).toBe(true);
}, 100000);

it('acquires latest version of Mage', async () => {
const mage = await installer.getMage('latest', process.env.GITHUB_TOKEN || '');
const mage = await installer.getMage('latest');
expect(fs.existsSync(mage)).toBe(true);
}, 100000);
});
9 changes: 0 additions & 9 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,6 @@ inputs:
workdir:
description: 'Working directory (below repository root)'
required: false
github_token:
# https://github.com/actions/setup-go/blob/21459d0b7b1d63741429b748885bf5a4974593b4/action.yml#L12-L14
description: >
Used to verifiy the Git tag exists on docker/buildx repo. Since there's a
default, this is typically not supplied by the user. When running this
action on github.com, the default value is sufficient. When running on
GHES, you can pass a personal access token for github.com if you are
experiencing rate limiting.
default: ${{ github.server_url == 'https://github.com' && github.token || '' }}

runs:
using: 'node16'
Expand Down
3 changes: 1 addition & 2 deletions dev.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ ENV RUNNER_TEMP=/tmp/github_runner
ENV RUNNER_TOOL_CACHE=/tmp/github_tool_cache
RUN --mount=type=bind,target=.,rw \
--mount=type=cache,target=/src/node_modules \
--mount=type=secret,id=GITHUB_TOKEN \
GITHUB_TOKEN=$(cat /run/secrets/GITHUB_TOKEN) yarn run test --coverageDirectory=/tmp/coverage
yarn run test --coverageDirectory=/tmp/coverage

FROM scratch AS test-coverage
COPY --from=test /tmp/coverage /
8 changes: 1 addition & 7 deletions dist/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

Loading