-
Notifications
You must be signed in to change notification settings - Fork 79
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
Roy Razon
committed
Dec 14, 2023
1 parent
7696f78
commit 154dcef
Showing
71 changed files
with
789 additions
and
165 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
site | ||
.eslintrc.js | ||
.eslintrc.cjs | ||
build_utils |
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 |
---|---|---|
|
@@ -10,9 +10,6 @@ node_modules/ | |
# Coverage | ||
coverage | ||
|
||
# Transpiled files | ||
build/ | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
|
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
/.eslintrc.js | ||
/.eslintrc.cjs | ||
/dist | ||
/build.mjs |
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 @@ | ||
module.exports = require('../../build_utils/eslintrc.cjs') |
This file was deleted.
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
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 @@ | ||
module.exports = require('../../build_utils/eslintrc.cjs') |
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,7 @@ node_modules/ | |
coverage | ||
|
||
# Transpiled files | ||
build/ | ||
/build/ | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
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
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
/.eslintrc.js | ||
/.eslintrc.cjs | ||
/dist | ||
/build.mjs |
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 @@ | ||
module.exports = require('../../build_utils/eslintrc.cjs') |
This file was deleted.
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
/.eslintrc.js | ||
/.eslintrc.cjs | ||
/dist | ||
/build.mjs |
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 @@ | ||
module.exports = require('../../build_utils/eslintrc.cjs') |
This file was deleted.
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
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
/.eslintrc.js | ||
/.eslintrc.cjs | ||
/dist | ||
/build.mjs |
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 @@ | ||
module.exports = require('../../build_utils/eslintrc.cjs') |
This file was deleted.
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,96 @@ | ||
import { beforeEach, describe, it, expect } from '@jest/globals' | ||
import { GitContext } from '../git.js' | ||
import { FsReader } from '../store/index.js' | ||
import { MockFunctions, mockFunction } from '../test-helpers.js' | ||
import { ImageTagCalculator, imageTagCalculator } from './image-tag.js' | ||
|
||
describe('imageTagCalculator', () => { | ||
const dockerfileContents = 'FROM my-image' | ||
|
||
type PartialGitContext = Pick<GitContext, 'commit' | 'localChanges'> | ||
|
||
let mockReader: MockFunctions<FsReader> | ||
beforeEach(() => { | ||
mockReader = { read: mockFunction<FsReader['read']>() } | ||
}) | ||
|
||
let mockGitContextCreator: () => PartialGitContext | ||
let mockGitContext: MockFunctions<PartialGitContext> | ||
beforeEach(() => { | ||
mockGitContext = { | ||
commit: mockFunction<GitContext['commit']>(async () => 'abcdef'), | ||
localChanges: mockFunction<GitContext['localChanges']>(async () => ''), | ||
} | ||
mockGitContextCreator = mockFunction<() => PartialGitContext>(() => mockGitContext) | ||
}) | ||
|
||
describe('sanity', () => { | ||
let c: ImageTagCalculator | ||
let tag: string | ||
|
||
beforeEach(async () => { | ||
c = imageTagCalculator({ | ||
gitContext: mockGitContextCreator, | ||
fsReader: mockReader, | ||
}) | ||
|
||
tag = await c({ | ||
context: '/context', | ||
dockerfile: 'Dockerfile', | ||
}) | ||
}) | ||
|
||
it('should call the commit function correctly', async () => { | ||
expect(mockGitContext.commit).toHaveBeenCalledWith({ short: true }) | ||
}) | ||
|
||
it('should generate a tag', async () => { | ||
expect(tag).toMatch(/^[a-z0-9-]+$/) | ||
}) | ||
|
||
it('should generate the same tag for the same build', async () => { | ||
expect(await c({ | ||
context: '/context', | ||
dockerfile: 'Dockerfile', | ||
})).toEqual(tag) | ||
}) | ||
|
||
it('should generate the same tag if the dockerfile path changed', async () => { | ||
expect(await c({ | ||
context: '/context', | ||
dockerfile: 'Dockerfile.a', | ||
})).toEqual(tag) | ||
}) | ||
|
||
it('should generate a different tag if the context changed', async () => { | ||
expect(await c({ | ||
context: '/context/a', | ||
dockerfile: 'Dockerfile', | ||
})).not.toEqual(tag) | ||
}) | ||
|
||
it('should generate a different tag if the dockerfile contents changed', async () => { | ||
mockReader.read.mockResolvedValue(Buffer.from(`${dockerfileContents}a`)) | ||
expect(await c({ | ||
context: '/context/a', | ||
dockerfile: 'Dockerfile', | ||
})).not.toEqual(tag) | ||
}) | ||
|
||
it('should generate a different tag if the build args changed', async () => { | ||
expect(await c({ | ||
context: '/context/a', | ||
dockerfile: 'Dockerfile', | ||
args: { foo: 'bar' }, | ||
})).not.toEqual(tag) | ||
}) | ||
|
||
it('should generate a different tag if the build target changed', async () => { | ||
expect(await c({ | ||
context: '/context/a', | ||
dockerfile: 'Dockerfile', | ||
target: 'dev', | ||
})).not.toEqual(tag) | ||
}) | ||
}) | ||
}) |
Oops, something went wrong.