Skip to content
This repository has been archived by the owner on Jul 24, 2022. It is now read-only.

Commit

Permalink
Merge pull request #55 from liiingo/main
Browse files Browse the repository at this point in the history
Allow customizable working directory for monorepo support
  • Loading branch information
trymbill authored Feb 5, 2021
2 parents 4db48df + 8c61d96 commit 4067c6b
Show file tree
Hide file tree
Showing 8 changed files with 344 additions and 260 deletions.
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v12.19.0
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,19 @@ This Github action enables you to take the screenshots and videos generated by C

**Required** Slack channels to upload to

### `workdir`

**Optional** The folder where Cypress stores screenshots and videos on the build machine.

Default: `cypress`

(this relative path resolves to `/home/runner/work/<REPO_NAME>/<REPO_NAME>/cypress`)

If your project uses Cypress from the project root folder, the default value will work for you.
But if your project uses Cypress in a subfolder (like most monorepos), you'll need to provide the relative path to that folder
(i.e. `e2e/cypress`).
(Don't include a trailing slash on your path!)

## Examples

### Upload results after every push
Expand Down
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ inputs:
channels:
description: 'Slack channels'
required: true
workdir:
description: 'The path of the directory where Cypress stores its screenshots. Defaults to `./cypress`. No trailing slashes, please.'
required: false
outputs:
result:
description: 'Result of video and screenshot uploads'
Expand Down
572 changes: 319 additions & 253 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.

2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cypress-slack-video-upload-action",
"version": "1.0.0",
"version": "1.1.1",
"private": true,
"description": "Github action that takes the generated screenshots and videos from a Cypress test and uploads them to Slack",
"main": "lib/main.js",
Expand Down
9 changes: 5 additions & 4 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ async function run(): Promise<void> {
core.debug('INIT!')
const token = core.getInput('token')
const channels = core.getInput('channels')
const workdir = core.getInput('workdir') || 'cypress'

core.debug(`Token: ${token}`)
core.debug(`Channels: ${channels}`)
Expand All @@ -17,8 +18,8 @@ async function run(): Promise<void> {
core.debug('Slack SDK initialized successfully')

core.debug('Checking for videos and/or screenshots from cypress')
const videos = walkSync('cypress', { globs: ['**/*.mp4'] })
const screenshots = walkSync('cypress', { globs: ['**/*.png'] })
const videos = walkSync(workdir, { globs: ['**/*.mp4'] })
const screenshots = walkSync(workdir, { globs: ['**/*.png'] })

if (videos.length <= 0 && screenshots.length <= 0) {
core.debug('No videos or screenshots found. Exiting!')
Expand Down Expand Up @@ -50,7 +51,7 @@ async function run(): Promise<void> {

await slack.files.upload({
filename: screenshot,
file: createReadStream(`cypress/${screenshot}`),
file: createReadStream(`${workdir}/${screenshot}`),
thread_ts: threadID,
channels: channelId
})
Expand All @@ -69,7 +70,7 @@ async function run(): Promise<void> {

await slack.files.upload({
filename: video,
file: createReadStream(`cypress/${video}`),
file: createReadStream(`${workdir}/${video}`),
thread_ts: threadID,
channels: channelId
})
Expand Down

0 comments on commit 4067c6b

Please sign in to comment.