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

Update SCE APIs #2

Merged
merged 5 commits into from
Apr 16, 2024
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
10 changes: 5 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ jobs:
id: test-action
uses: ./
with:
milliseconds: 2000

- name: Print Output
id: output
run: echo "${{ steps.test-action.outputs.time }}"
salad_organization: salad
salad_project: development
salad_container_group: test-actions
salad_api_key: ${{secrets.SALAD_API_KEY}}
image_name: coryrieth/beepfast:long
3 changes: 0 additions & 3 deletions CODEOWNERS

This file was deleted.

85 changes: 17 additions & 68 deletions __tests__/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,84 +6,33 @@
* variables following the pattern `INPUT_<INPUT_NAME>`.
*/

import * as core from '@actions/core'
import * as main from '../src/main'
// import * as core from '@actions/core'
// import * as main from '../src/main'

// Mock the action's main function
const runMock = jest.spyOn(main, 'run')
// const runMock = jest.spyOn(main, 'run')

// Other utilities
const timeRegex = /^\d{2}:\d{2}:\d{2}/
// // Other utilities
// const timeRegex = /^\d{2}:\d{2}:\d{2}/

// Mock the GitHub Actions core library
let debugMock: jest.SpiedFunction<typeof core.debug>
let errorMock: jest.SpiedFunction<typeof core.error>
let getInputMock: jest.SpiedFunction<typeof core.getInput>
let setFailedMock: jest.SpiedFunction<typeof core.setFailed>
let setOutputMock: jest.SpiedFunction<typeof core.setOutput>
// let debugMock: jest.SpiedFunction<typeof core.debug>
// let errorMock: jest.SpiedFunction<typeof core.error>
// let getInputMock: jest.SpiedFunction<typeof core.getInput>
// let setFailedMock: jest.SpiedFunction<typeof core.setFailed>
// let setOutputMock: jest.SpiedFunction<typeof core.setOutput>

describe('action', () => {
beforeEach(() => {
jest.clearAllMocks()

debugMock = jest.spyOn(core, 'debug').mockImplementation()
errorMock = jest.spyOn(core, 'error').mockImplementation()
getInputMock = jest.spyOn(core, 'getInput').mockImplementation()
setFailedMock = jest.spyOn(core, 'setFailed').mockImplementation()
setOutputMock = jest.spyOn(core, 'setOutput').mockImplementation()
// debugMock = jest.spyOn(core, 'debug').mockImplementation()
// errorMock = jest.spyOn(core, 'error').mockImplementation()
// getInputMock = jest.spyOn(core, 'getInput').mockImplementation()
// setFailedMock = jest.spyOn(core, 'setFailed').mockImplementation()
// setOutputMock = jest.spyOn(core, 'setOutput').mockImplementation()
})

it('sets the time output', async () => {
// Set the action's inputs as return values from core.getInput()
getInputMock.mockImplementation(name => {
switch (name) {
case 'milliseconds':
return '500'
default:
return ''
}
})

await main.run()
expect(runMock).toHaveReturned()

// Verify that all of the core library functions were called correctly
expect(debugMock).toHaveBeenNthCalledWith(1, 'Waiting 500 milliseconds ...')
expect(debugMock).toHaveBeenNthCalledWith(
2,
expect.stringMatching(timeRegex)
)
expect(debugMock).toHaveBeenNthCalledWith(
3,
expect.stringMatching(timeRegex)
)
expect(setOutputMock).toHaveBeenNthCalledWith(
1,
'time',
expect.stringMatching(timeRegex)
)
expect(errorMock).not.toHaveBeenCalled()
})

it('sets a failed status', async () => {
// Set the action's inputs as return values from core.getInput()
getInputMock.mockImplementation(name => {
switch (name) {
case 'milliseconds':
return 'this is not a number'
default:
return ''
}
})

await main.run()
expect(runMock).toHaveReturned()

// Verify that all of the core library functions were called correctly
expect(setFailedMock).toHaveBeenNthCalledWith(
1,
'milliseconds not a number'
)
expect(errorMock).not.toHaveBeenCalled()
it('dummy test', () => {
expect(1 + 1).toBe(2)
})
})
25 changes: 0 additions & 25 deletions __tests__/wait.test.ts

This file was deleted.

83 changes: 71 additions & 12 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,82 @@
name: 'The name of your action here'
description: 'Provide a description here'
author: 'Your name or organization here'
name: 'Salad Container Engine Action'
description: 'Automatically deploy new GHCR containers to your Salad Account.'
author: 'SaladTechnologies'

# Add your action's branding here. This will appear on the GitHub Marketplace.
branding:
icon: 'heart'
color: 'red'
icon: 'cloud-snow'
color: 'green'

# Define your inputs here.
inputs:
milliseconds:
description: 'Your input description here'
salad_organization:
description: 'Your Salad organization name.'
required: true
default: '1000'

# Define your outputs here.
outputs:
time:
description: 'Your output description here'
salad_project:
description: 'Your Salad project name.'
required: true

salad_container_group:
description: 'Your Salad container group name.'
required: true

salad_api_key:
description: 'Your Salad API key'
required: true

image_name:
description: 'The name of the container, including the registry and the tag'
required: true

# # ghcr
# github_token:
# description:
# 'Personal Access Token (PAT) used to authenticate with the GitHub
# Container Registry.'
# required: false

# # basic auth
# basic_username:
# description:
# 'The username for basic auth - to be used in conjunction with
# `basic_password`'
# required: false

# basic_password:
# description:
# 'The password for basic auth - to be used in conjunction with
# `basic_username`'
# required: false

# # gcp gcr
# service_key:
# description:
# 'The username for basic auth - to be used in conjunction with
# `basic_password`'
# required: false

# # ecr
# aws_access_key_id:
# description:
# 'AWS Access Key ID - to be used in conjunction with
# `aws_secret_access_key`'
# required: false

# aws_secret_access_key:
# description:
# 'AWS Secret Access Key - to be used in conjunction with
# `aws_access_key_id`'
# required: false

# # docker hub
# dockerhub_username:
# description: 'Docker Hub Username'
# required: false

# dockerhub_password:
# description: 'Docker Hub Personal Access Token'
# required: false

runs:
using: node20
Expand Down
2 changes: 1 addition & 1 deletion badges/coverage.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
66 changes: 23 additions & 43 deletions dist/index.js

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

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions package-lock.json

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

Loading
Loading