Skip to content
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
13 changes: 13 additions & 0 deletions __mocks__/@actions/github.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const fs = require('fs')

class Context {
constructor() {
this.payload = process.env.GITHUB_EVENT_PATH
? JSON.parse(fs.readFileSync(process.env.GITHUB_EVENT_PATH, 'utf8'))
: {}
this.eventName = process.env.GITHUB_EVENT_NAME
this.actor = process.env.GITHUB_ACTOR
}
}

module.exports.context = new Context()
5 changes: 4 additions & 1 deletion __tests__/inputs.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import {Context} from '@actions/github/lib/context'
import {context as githubContext} from '@actions/github'
import {getJobParameters} from '../src/inputs'
import {eventFixturePath} from './helpers'

type Context = typeof githubContext
const Context = githubContext.constructor as new () => Context

let context: Context

describe('when there is a fully configured Actions environment', () => {
Expand Down
5 changes: 4 additions & 1 deletion __tests__/main.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as core from '@actions/core'
import {Context} from '@actions/github/lib/context'
import {context as githubContext} from '@actions/github'
import {
ApiClient,
Credential,
Expand All @@ -16,6 +16,9 @@ import {run, credentialsFromEnv, getPackagesCredential} from '../src/main'

import {eventFixturePath} from './helpers'

type Context = typeof githubContext
const Context = githubContext.constructor as new () => Context

// We do not need to build actual containers or run updates for this test.
jest.mock('../src/image-service')
jest.mock('../src/updater')
Expand Down
17,270 changes: 9,820 additions & 7,450 deletions dist/cleanup.js

Large diffs are not rendered by default.

52,428 changes: 27,825 additions & 24,603 deletions dist/main.js

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ module.exports = {
testEnvironment: 'node',
testMatch: ['**/*.test.ts'],
testRunner: 'jest-circus/runner',
moduleNameMapper: {
'^@actions/github$': '<rootDir>/__mocks__/@actions/github.js',
'^@actions/http-client$':
'<rootDir>/node_modules/@actions/core/node_modules/@actions/http-client/lib/index.js'
},
transform: {
'^.+\\.ts$': 'ts-jest'
},
Expand Down
Loading
Loading