-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Rick Lane <[email protected]>
- Loading branch information
1 parent
bcd3035
commit 9ad7dac
Showing
8 changed files
with
88 additions
and
184 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,12 @@ | ||
# Infra-actions documentation | ||
# Infra-actions | ||
|
||
## GitHub | ||
- [Using the GitHub actions matrix strategy](./docs/GITHUB_ACTIONS.md) | ||
- [Self-hosted GitHub action runners](./github-runner-provisioner/README.md) | ||
## Clusters | ||
- [Cluster provisioning with custom manifests](./setup-cluster/README.md) | ||
## Dev loop | ||
- [DEVELOPING.md](docs/DEVELOPING.md) | ||
|
||
- [Github Actions for Test Matrices](docs/GITHUB_ACTIONS.md) | ||
- [Custom GitHub action runners](docs/ACTION_RUNNERS.md) | ||
- [Self-hosted GitHub action runners](github-runner-provisioner/README.md) | ||
|
||
## Development | ||
|
||
- [Working with GitHub workflows and actions](docs/DEVELOPING.md) | ||
- [Provision Cluster GitHub Action](provision-cluster/README.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,71 +1,56 @@ | ||
# Runner Service | ||
# Self-hosted GitHub action runners | ||
|
||
This service is based on the [echo | ||
template](https://github.com/datawire/infrastructure/tree/master/echo). Please view the | ||
[README](https://github.com/datawire/infrastructure/tree/master/echo) for details about the dev loop | ||
and how it works. | ||
This service is based on the [echo template](https://github.com/datawire/infrastructure/tree/master/echo). Please view the [README](https://github.com/datawire/infrastructure/tree/master/echo) for details about the dev loop and how it works. | ||
|
||
# Architecture | ||
## Architecture | ||
|
||
We use the GitHub-Runner-Provisioner to serve a webhook to GitHub Actions. GitHub will send any | ||
Actions events to the GRP running in Skunkworks, which will parse those events looking for | ||
workflows that request special labels in their `runs-on` property. | ||
We use the GitHub-Runner-Provisioner to serve a webhook to GitHub Actions. GitHub will send any Actions events to the GRP running in Skunkworks, which will parse those events looking for workflows that request special labels in their `runs-on` property. | ||
|
||
Using the GitHub Self-Hosted Runner binaries we then spin up the custom runners in one of our | ||
supported runner providers - currently AWS and CodeMagic. Supported runners are configured in | ||
[runner.go](runner.go). | ||
Using the GitHub Self-Hosted Runner binaries we then spin up the custom runners in one of our supported runner providers - currently AWS and CodeMagic. Supported runners are configured in [runner.go](runner.go). | ||
|
||
## AWS | ||
### AWS | ||
|
||
AWS runners are created in EC2 using the AWS SDK. See the [aws_runners](internal/aws/runners) | ||
package for details on the implementation. | ||
AWS runners are created in EC2 using the AWS SDK. See the [aws_runners](internal/aws/runners) package for details on the implementation. | ||
|
||
## CodeMagic | ||
### CodeMagic | ||
|
||
CodeMagic runners are actually CodeMagic Builds (CI jobs in their service) that then pull the | ||
GitHub Self-Hosted binaries and register themselves as ephemeral (single-use) runners - picking | ||
up a single job from the calling repo and then terminating. | ||
CodeMagic runners are actually CodeMagic Builds (CI jobs in their service) that then pull the GitHub Self-Hosted binaries and register themselves as ephemeral (single-use) runners - picking up a single job from the calling repo and then terminating. | ||
|
||
# Testing the application | ||
## Testing the application | ||
|
||
## Integration Tests | ||
### Integration Tests | ||
|
||
**Note**: Before running tests, make sure you run the application with environment variable `WEBHOOK_TOKEN=FAKE_TOKEN`. | ||
You will also need to set `GITHUB_TOKEN` to a PAT for the D6E Automaton. These values can all be found in the | ||
[github-runner-provisioner-secrets.yaml](/keybase/team/datawireio/skunkworks/github-runner-provisioner-secrets.yaml) | ||
file in Keybase - you will need to base64 decode them before use. If only running dry-runs only AWS and GitHub | ||
authentication is required. | ||
|
||
To test the application we use targets in the Makefile. The `make go-unit-tests` target will run the unit tests, | ||
and `make test-runners` will run the integration tests against the dry-run endpoints. Note that to test the | ||
AWS `macOS-arm64` runner you will need to set the `USE_CODEMAGIC` environment variable to `true` in the GRP. | ||
You will also need to set `GITHUB_TOKEN` to a PAT for the D6E Automaton. These values can all be found in the [github-runner-provisioner-secrets.yaml](/keybase/team/datawireio/skunkworks/github-runner-provisioner-secrets.yaml) file in Keybase - you will need to base64 decode them before use. If only running dry-runs only AWS and GitHub authentication is required. | ||
|
||
To test the application we use targets in the Makefile. The `make go-unit-tests` target will run the unit tests, and `make test-runners` will run the integration tests against the dry-run endpoints. Note that to test the AWS `macOS-arm64` runner you will need to set the `USE_CODEMAGIC` environment variable to `true` in the GRP. | ||
|
||
Testing CodeMagic M1 & AWS ubuntu-arm64: | ||
|
||
Testing CodeMagic M1 & AWS ubuntu-arm64: | ||
```bash | ||
USE_CODEMAGIC=true GITHUB_TOKEN=<pat> go run main.go --dry-run | ||
make test-runners | ||
USE_CODEMAGIC=true GITHUB_TOKEN=<pat> go run main.go --dry-run | ||
make test-runners | ||
``` | ||
|
||
**Note**: You can send requests to the production client using `make run-<runner tag>` Be careful when sending | ||
requests to production using an HTTP client, since the `dry-run` | ||
request parameter defaults to true. This is necessary because we have no way to set GitHub to send this | ||
parameter. | ||
**Note**: You can send requests to the production client using `make run-<runner tag>` Be careful when sending requests to production using an HTTP client, since the `dry-run` request parameter defaults to true. This is necessary because we have no way to set GitHub to send this parameter. | ||
|
||
## Unit tests | ||
### Unit tests | ||
|
||
Some unit tests use mocks generated by gomock. If the interface being mocked is updated, you may have to re-generate the | ||
mocks by running: | ||
Some unit tests use mocks generated by gomock. If the interface being mocked is updated, you may have to re-generate the mocks by running: | ||
|
||
```shell | ||
make update-go-mocks | ||
make update-go-mocks | ||
``` | ||
|
||
# Env Vars | ||
## Env Vars | ||
|
||
The runner provisioner requires the following variables to be configured: | ||
- `GITHUB_TOKEN` - a personal access token with admin access to the repo configuring the runners. | ||
We use the `D6E-Automaton`'s token in production. | ||
- `WEBHOOK_TOKEN` - the secret used to configure the webhook in GitHub. We use the token stored at | ||
`/Keybase/team/datawireio/infra/github-runner-provisioner-secrets` | ||
|
||
- `GITHUB_TOKEN` - a personal access token with admin access to the repo configuring the runners. | ||
We use the `D6E-Automaton`'s token in production. | ||
- `WEBHOOK_TOKEN` - the secret used to configure the webhook in GitHub. We use the token stored at | ||
`/Keybase/team/datawireio/infra/github-runner-provisioner-secrets` | ||
- `CODEMAGIC_TOKEN` - the secret used to authenticate to the CodeMagic build API to trigger M1 runners | ||
- `USE_CODEMAGIC` - a boolean flag to indicate whether to use CodeMagic or AWS to provision M1 runners | ||
- AWS auth can be configured with `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` or by using the aws cli | ||
- AWS auth can be configured with `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` or by using the aws cli |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,27 @@ | ||
# Documentation to enable developing and releasing the items in this repository. | ||
# Provision Cluster GitHub Action | ||
|
||
## Releasing the provision-cluster GitHub Action: | ||
## Releasing the provision-cluster GitHub Action | ||
|
||
GitHub Actions are released by creating a semver tag and pushing it to GitHub. No additional steps | ||
are needed. | ||
GitHub Actions are released by creating a semver tag and pushing it to GitHub. No additional steps are needed. | ||
|
||
### Step 1: Query existing tags | ||
|
||
Use `git pull` to make sure you have all tags locally and then use `git tag -l` to find existing tag | ||
names. Release tags are of the form `vX.Y.Z` and release versions should follow semver. | ||
Use `git pull` to make sure you have all tags locally and then use `git tag -l` to find existing tag names. Release tags are of the form `vX.Y.Z` and release versions should follow semver. | ||
|
||
### Step 2: Tag with your new version number | ||
|
||
Use `git tag vX.Y.Z` to tag with your new version number, and then run `git push --tags` to push the | ||
new tag up to GitHub. | ||
Use `git tag vX.Y.Z` to tag with your new version number, and then run `git push --tags` to push the new tag up to GitHub. | ||
|
||
### Step 3: Verify the release works by updating the smoke test workflow. | ||
### Step 3: Verify the release works by updating the smoke test workflow | ||
|
||
Once the tag is pushed, then verify the release by using it in the smoke test workflow. Do this by | ||
editing `.github/workflows/smoke.yaml`, search for the uses line and update the version to the newly | ||
released tag, e.g.: | ||
Once the tag is pushed, then verify the release by using it in the smoke test workflow. Do this by editing `.github/workflows/smoke.yaml`, search for the uses line and update the version to the newly released tag. | ||
|
||
``` | ||
... | ||
- uses: datawire/infra-actions/[email protected] | ||
... | ||
```yaml | ||
jobs: | ||
release_smoke: | ||
steps: | ||
- id: provision | ||
uses: datawire/infra-actions/[email protected] | ||
``` | ||
Pushing the tag should trigger the release smoke test workflow. Verify that this has in fact passed. |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.