Skip to content

Commit

Permalink
Wired together
Browse files Browse the repository at this point in the history
  • Loading branch information
ravenac95 committed Mar 20, 2024
1 parent 4b06526 commit 963237b
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 3 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/external-prs-handle-comment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,21 @@ jobs:
# run: |
# bashf

- name: Login to google
uses: 'google-github-actions/auth@v2'
with:
credentials_json: '${{ secrets.GOOGLE_BQ_ADMIN_CREDENTIALS_JSON }}'
create_credentials_file: true
if: ${{ steps.parse_comment.outputs.deploy == 'true' }}

- name: Run test-deploy
uses: ./.github/workflows/test-deploy
with:
sha: ${{ steps.parse_comment.outputs.sha }}
pr: ${{ steps.parse_comment.outputs.pr }}
requester: ${{ steps.parse_comment.outputs.comment_author }}
author: ${{ steps.parse_comment.outputs.issue_author }}
gcp_service_account_path: ${{ env.GOOGLE_APPLICATION_CREDENTIALS }}

# This check isn't for security it's mostly a convenience so this won't
# fail and muddy up the actions UI
Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/test-deploy-owners.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,21 @@ jobs:
cd ops/external-prs &&
pnpm tools initialize-check ${{ github.repository }} ${{ github.event.pull_request.head.sha }} ${{ github.event.sender.login }}
- name: Login to google
uses: 'google-github-actions/auth@v2'
with:
credentials_json: '${{ secrets.GOOGLE_BQ_ADMIN_CREDENTIALS_JSON }}'
create_credentials_file: true
if: ${{ contains(fromJson('["OWNER", "MEMBER", "COLLABORATOR"]'), github.event.pull_request.author_association) }}

- name: Run test-deploy
uses: ./.github/workflows/test-deploy
with:
sha: ${{ github.event.pull_request.head.sha }}
pr: ${{ github.event.pull_request.id }}
requester: ${{ github.event.sender.login }}
author: ${{ github.event.sender.login }}
gcp_service_account_path: ${{ env.GOOGLE_APPLICATION_CREDENTIALS }}

# This check isn't for security it's mostly a convenience so this won't
# fail and muddy up the actions UI
Expand Down
20 changes: 20 additions & 0 deletions .github/workflows/test-deploy/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ inputs:
author:
description: The author of the pull
required: true
gcp_service_account_path:
description: The google service account
required: true

runs:
using: "composite"
Expand All @@ -39,4 +42,21 @@ runs:
# run: |
# cd ops/external-prs && pnpm tools test-deploy is-eligible $GITHUB_OUTPUT

- name: checkout the PR
uses: actions/checkout@v3
with:
# Check out pull request's HEAD commit instead of the merge commit to
# prevent gitlint from failing due to too long commit message titles,
# e.g. "Merge 3e621938d65caaa67f8e35d145335d889d470fc8 into 19a39b2f66cd7a165082d1486b2f1eb36ec2354a".
ref: ${{ inputs.sha }}
# Fetch all history so gitlint can check the relevant commits.
fetch-depth: "1"

path: "pr-clone/"

- name: Run test-deploy
run: |
mkdir -p $HOME/.dbt &&
cd ops/external-prs && pnpm tools test-deploy ${{ github.repository }} ${{ inputs.pr }} $HOME/.dbt/profiles ${{ inputs.gcp_service_account_path }}
14 changes: 11 additions & 3 deletions ops/external-prs/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,11 @@ interface TestDeployArgs extends BaseArgs {

interface TestDeploySetupArgs extends TestDeployArgs {
pr: number;
sha: number;
sha: string;
profilePath: string;
serviceAccountPath: string;
projectId: string;
checkoutPath: string;
}

interface TestDeployPeriodicCleaningArgs extends TestDeployArgs {
Expand Down Expand Up @@ -273,9 +274,10 @@ async function refreshCredentials(args: RefreshGCPCredentials) {
async function testDeploySetup(args: TestDeploySetupArgs) {
return args.coordinator.setup(
args.pr,
args.sha,
args.profilePath,
args.serviceAccountPath,
args.sha,
args.checkoutPath,
);
}

Expand Down Expand Up @@ -316,18 +318,24 @@ function testDeployGroup(group: Argv) {
);
})
.command<TestDeploySetupArgs>(
"setup <repo> <pr> <profile-path> <service-account-path>",
"setup <repo> <pr> <sha> <profile-path> <service-account-path> <checkout-path>",
"subcommand for a setting up a test deployment",
(yags) => {
yags.positional("pr", {
description: "The PR",
});
yags.positional("sha", {
description: "the sha to deploy",
});
yags.positional("profile-path", {
description: "the profile path to write to",
});
yags.positional("service-account-path", {
description: "the profile path to write to",
});
yags.positional("checkout-path", {
description: "the path to the checked out code",
});
},
(args) => handleError(testDeploySetup(args)),
)
Expand Down

0 comments on commit 963237b

Please sign in to comment.