-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c792abc
commit 95eeb57
Showing
13 changed files
with
23,804 additions
and
208 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
name: 'Dagster Cloud Code Preview' | ||
description: | | ||
'Builds the Dagster repo Docker images and creates a preview link to view the Dagster Cloud repo locations.' | ||
branding: | ||
icon: 'eye' | ||
color: 'white' | ||
inputs: | ||
github-token: | ||
description: 'Github API token' | ||
required: true | ||
dagit-url: | ||
description: 'Dagster Cloud Dagit URL' | ||
required: true | ||
api-token: | ||
description: 'Cloud Agent API token' | ||
required: true | ||
location-file: | ||
description: 'Path to the locations.yaml file defining the repo locations to update' | ||
required: true | ||
default: 'locations.yaml' | ||
parallel: | ||
description: 'Whether to build and push all Docker images in parallel' | ||
required: false | ||
default: true | ||
runs: | ||
using: 'node12' | ||
main: '../dist/preview/index.js' |
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 |
---|---|---|
@@ -0,0 +1,107 @@ | ||
const core = require("@actions/core"); | ||
const exec = require("@actions/exec"); | ||
const github = require("@actions/github"); | ||
const { DagsterCloudClient } = require("./dagsterCloud"); | ||
const { | ||
getProcess, | ||
getLocations, | ||
buildDockerImages, | ||
createCommentOnCommit, | ||
} = require("./utils"); | ||
|
||
async function run() { | ||
try { | ||
const imageTag = github.context.sha.substring(0, 6); | ||
|
||
const locationFile = core.getInput("location-file"); | ||
|
||
const locations = await getLocations(locationFile); | ||
|
||
const parallel = core.getBooleanInput("parallel"); | ||
const process = getProcess(parallel); | ||
|
||
await buildDockerImages(process, locationFile, locations, imageTag); | ||
|
||
await core.group("Create code preview", async () => { | ||
const dagitUrl = core.getInput("dagit-url"); | ||
const endpoint = `${dagitUrl}/graphql`; | ||
|
||
const apiToken = core.getInput("api-token"); | ||
|
||
const client = new DagsterCloudClient(endpoint, apiToken); | ||
|
||
core.info(github.context.pull_request); | ||
|
||
const commitSha = github.context.payload.pull_request.head.sha; | ||
const codePreview = { | ||
commitMessage: github.context.payload.pull_request.head.label, | ||
branchName: github.context.payload.pull_request.head.ref, | ||
branchUrl: github.context.payload.pull_request.html_url, | ||
commitSha: commitSha, | ||
commitUrl: `${github.context.payload.pull_request.html_url}/commits/${commitSha}`, | ||
}; | ||
|
||
const codePreviewId = await client.createCodePreview(codePreview); | ||
|
||
await process(locations, async ([locationName, location]) => { | ||
const pythonFile = location["python_file"]; | ||
const packageName = location["package_name"]; | ||
const moduleName = location["module_name"]; | ||
const workingDirectory = location["working_directory"]; | ||
const executablePath = location["executable_path"]; | ||
const attribute = location["attribute"]; | ||
|
||
if ( | ||
[pythonFile, packageName, moduleName].filter((x) => !!x).length != 1 | ||
) { | ||
core.error( | ||
`Must provide exactly one of python_file, package_name, or module_name on location ${locationName}.` | ||
); | ||
} | ||
|
||
const imageName = `${location["registry"]}:${imageTag}`; | ||
const pythonFileArg = pythonFile ? ["--python-file", pythonFile] : []; | ||
const packageNameArg = packageName ? ["--package-name", packageName] : []; | ||
const moduleNameArg = moduleName ? ["--module-name", moduleName] : []; | ||
const workingDirectoryArg = workingDirectory ? ["--working-directory", workingDirectory]: []; | ||
const executablePathArg = executablePath ? ["--executable-path", executablePath] : []; | ||
const attributeArg = attribute ? ["--attribute", attribute] : []; | ||
|
||
await exec.exec( | ||
"docker", | ||
[ | ||
"run", | ||
imageName, | ||
"dagster-cloud", | ||
"workspace", | ||
"snapshot", | ||
locationName, | ||
codePreviewId, | ||
"--url", | ||
dagitUrl, | ||
"--api-token", | ||
apiToken, | ||
"--image", | ||
imageName, | ||
] | ||
.concat(pythonFileArg) | ||
.concat(packageNameArg) | ||
.concat(moduleNameArg) | ||
.concat(workingDirectoryArg) | ||
.concat(executablePathArg) | ||
.concat(attributeArg) | ||
); | ||
|
||
core.info( | ||
`Successfully created repository location for code preview ${codePreviewId}` | ||
); | ||
|
||
await createCommentOnCommit(codePreviewId); | ||
}); | ||
}); | ||
} catch (error) { | ||
core.setFailed(error.message); | ||
} | ||
} | ||
|
||
run(); |
Oops, something went wrong.