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

don't depend on the GitHub API to check release #196

Merged
merged 2 commits into from
Jan 30, 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 @@ -30,8 +30,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
30 changes: 0 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ ___
* [Notes](#notes)
* [`nodes` output](#nodes-output)
* [BuildKit container logs](#buildkit-container-logs)
* [Using on GHES](#using-on-ghes)
* [Contributing](#contributing)

## Usage
Expand Down Expand Up @@ -175,35 +174,6 @@ The following [official docker environment variables](https://docs.docker.com/en

See https://docs.docker.com/build/ci/github-actions/configure-builder/#buildkit-container-logs

## Using on GHES

GitHub Runners come [pre-installed with Docker Buildx](https://github.com/actions/runner-images/blob/main/images/linux/Ubuntu2204-Readme.md)
following your virtual environment. If you specify a version or `latest` of
Docker Buildx in your workflow, the version will be downloaded from [GitHub Releases in `docker/buildx`](https://github.com/docker/buildx/releases)
repository. These calls to `docker/buildx` 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: docker/setup-buildx-action@v2
with:
github_token: ${{ secrets.GH_DOTCOM_TOKEN }}
version: v0.10.1
```

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/enterprise-server/admin/github-actions/managing-access-to-actions-from-githubcom/setting-up-the-tool-cache-on-self-hosted-runners-without-internet-access)"
for more information.

## Contributing

Want to contribute? Awesome! You can find information about contributing to
Expand Down
30 changes: 29 additions & 1 deletion __tests__/buildx.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,34 @@ describe('isAvailable', () => {
});
});

describe('getRelease', () => {
jedevc marked this conversation as resolved.
Show resolved Hide resolved
it('returns latest buildx GitHub release', async () => {
const release = await buildx.getRelease('latest');
expect(release).not.toBeNull();
expect(release?.tag_name).not.toEqual('');
});

it('returns v0.10.1 buildx GitHub release', async () => {
const release = await buildx.getRelease('v0.10.1');
expect(release).not.toBeNull();
expect(release?.id).toEqual(90346950);
expect(release?.tag_name).toEqual('v0.10.1');
expect(release?.html_url).toEqual('https://github.com/docker/buildx/releases/tag/v0.10.1');
});

it('returns v0.2.2 buildx GitHub release', async () => {
const release = await buildx.getRelease('v0.2.2');
expect(release).not.toBeNull();
expect(release?.id).toEqual(17671545);
expect(release?.tag_name).toEqual('v0.2.2');
expect(release?.html_url).toEqual('https://github.com/docker/buildx/releases/tag/v0.2.2');
});

it('unknown release', async () => {
await expect(buildx.getRelease('foo')).rejects.toThrowError(new Error('Cannot find Buildx release foo in https://raw.githubusercontent.com/docker/buildx/master/.github/releases.json'));
});
});

describe('isAvailable standalone', () => {
const execSpy = jest.spyOn(exec, 'getExecOutput');
buildx.isAvailable(true);
Expand Down Expand Up @@ -221,7 +249,7 @@ describe('install', () => {
])(
'acquires %p of buildx (standalone: %p)',
async (version, standalone) => {
const buildxBin = await buildx.install(version, process.env.GITHUB_TOKEN || '', tmpDir, standalone);
const buildxBin = await buildx.install(version, tmpDir, standalone);
expect(fs.existsSync(buildxBin)).toBe(true);
},
100000
Expand Down
20 changes: 0 additions & 20 deletions __tests__/github.test.ts

This file was deleted.

9 changes: 0 additions & 9 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,6 @@ inputs:
append:
description: 'Append additional nodes to the builder'
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 || '' }}

outputs:
name:
Expand Down
3 changes: 1 addition & 2 deletions dev.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@ RUN --mount=type=bind,target=.,rw \
--mount=type=cache,target=/src/node_modules \
--mount=type=bind,from=docker,source=/usr/local/bin/docker,target=/usr/bin/docker \
--mount=type=bind,from=buildx,source=/buildx,target=/usr/libexec/docker/cli-plugins/docker-buildx \
--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 /
10 changes: 2 additions & 8 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