forked from satackey/action-docker-layer-caching
-
Notifications
You must be signed in to change notification settings - Fork 10
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bump dependencies flagged by dependabot #12
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
af759e1
Bump dependencies flagged by dependabot
jpribyl bd85c2a
Update author, repo, version
jpribyl 7012290
Remove ttsc from post.ts
jpribyl 47f2bd3
Remove manifest check
jpribyl 4c84bee
Update manifest check to use 'satisfies' operator
jpribyl File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
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,43 +1,68 @@ | ||
import * as core from '@actions/core' | ||
import * as core from "@actions/core"; | ||
|
||
import { LayerCache } from './src/LayerCache' | ||
import { ImageDetector } from './src/ImageDetector' | ||
import { assertType } from 'typescript-is' | ||
import { LayerCache } from "./src/LayerCache"; | ||
import { ImageDetector } from "./src/ImageDetector"; | ||
|
||
const main = async () => { | ||
if (JSON.parse(core.getInput('skip-save', { required: true }))) { | ||
core.info('Skipping save.') | ||
return | ||
if (JSON.parse(core.getInput("skip-save", { required: true }))) { | ||
core.info("Skipping save."); | ||
return; | ||
} | ||
|
||
const primaryKey = core.getInput('key', { required: true }) | ||
const primaryKey = core.getInput("key", { required: true }); | ||
|
||
const restoredKey = JSON.parse(core.getState(`restored-key`)) | ||
const alreadyExistingImages = JSON.parse(core.getState(`already-existing-images`)) | ||
const restoredImages = JSON.parse(core.getState(`restored-images`)) | ||
const restoredKey = JSON.parse(core.getState(`restored-key`)); | ||
const alreadyExistingImages = JSON.parse( | ||
core.getState(`already-existing-images`) | ||
); | ||
const restoredImages = JSON.parse(core.getState(`restored-images`)); | ||
|
||
assertType<string>(restoredKey) | ||
assertType<string[]>(alreadyExistingImages) | ||
assertType<string[]>(restoredImages) | ||
if (typeof restoredKey !== "string") { | ||
throw Error( | ||
`restoredKey is not of type string, instead it is of type ${typeof restoredKey}` | ||
); | ||
} | ||
alreadyExistingImages.map((image: string) => { | ||
if (typeof image !== "string") { | ||
throw Error( | ||
`alreadyExistingImage is not of type string, instead it is of type ${typeof image}` | ||
); | ||
} | ||
}); | ||
restoredImages.map((image: string) => { | ||
if (typeof image !== "string") { | ||
throw Error( | ||
`restoredImage is not of type string, instead it is of type ${typeof image}` | ||
); | ||
} | ||
}); | ||
|
||
const imageDetector = new ImageDetector() | ||
const imageDetector = new ImageDetector(); | ||
|
||
const existingAndRestoredImages = alreadyExistingImages.concat(restoredImages) | ||
const newImages = await imageDetector.getImagesShouldSave(existingAndRestoredImages) | ||
const existingAndRestoredImages = | ||
alreadyExistingImages.concat(restoredImages); | ||
const newImages = await imageDetector.getImagesShouldSave( | ||
existingAndRestoredImages | ||
); | ||
if (newImages.length < 1) { | ||
core.info(`There is no image to save.`) | ||
return | ||
core.info(`There is no image to save.`); | ||
return; | ||
} | ||
|
||
const imagesToSave = await imageDetector.getImagesShouldSave(alreadyExistingImages) | ||
const layerCache = new LayerCache(imagesToSave) | ||
layerCache.concurrency = parseInt(core.getInput(`concurrency`, { required: true }), 10) | ||
const imagesToSave = await imageDetector.getImagesShouldSave( | ||
alreadyExistingImages | ||
); | ||
const layerCache = new LayerCache(imagesToSave); | ||
layerCache.concurrency = parseInt( | ||
core.getInput(`concurrency`, { required: true }), | ||
10 | ||
); | ||
|
||
await layerCache.store(primaryKey) | ||
await layerCache.cleanUp() | ||
} | ||
await layerCache.store(primaryKey); | ||
await layerCache.cleanUp(); | ||
}; | ||
|
||
main().catch(e => { | ||
console.error(e) | ||
core.setFailed(e) | ||
}) | ||
main().catch((e) => { | ||
console.error(e); | ||
core.setFailed(e); | ||
}); |
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,26 +1,20 @@ | ||
import { assertType } from 'typescript-is' | ||
import { promises as fs } from 'fs' | ||
import * as path from 'path' | ||
import { promises as fs } from "fs"; | ||
import * as path from "path"; | ||
|
||
export interface Manifest { | ||
Config: string | ||
RepoTags: string[] | null | ||
Layers: string[] | ||
Config: string; | ||
RepoTags: string[] | null; | ||
Layers: string[]; | ||
} | ||
|
||
export type Manifests = Manifest[] | ||
|
||
export function assertManifests(x: unknown): asserts x is Manifests { | ||
assertType<Manifests>(x) | ||
} | ||
export type Manifests = Manifest[]; | ||
|
||
export async function loadRawManifests(rootPath: string) { | ||
return (await fs.readFile(path.join(rootPath, `manifest.json`))).toString() | ||
return (await fs.readFile(path.join(rootPath, `manifest.json`))).toString(); | ||
} | ||
|
||
export async function loadManifests(path: string) { | ||
const raw = await loadRawManifests(path) | ||
const manifests = JSON.parse(raw.toString()) | ||
assertManifests(manifests) | ||
return manifests | ||
const raw = await loadRawManifests(path); | ||
const manifests = JSON.parse(raw.toString()) satisfies Manifests; | ||
return manifests; | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, and looks like the builds are happy with it too. This work is satisfactory 馃槅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
awesome, I'll go ahead and merge it in- lmk if any issues come up- I'm not actively using this project a ton at the moment so you would likely find them before me 馃挭