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

Bump dive image version to 0.12, fix --ci-config and other issues #373

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open
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
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
root = true

[*]
indent_style = space
indent_size = 2
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
indent_size = 4
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,4 @@
"es6": true,
"jest/globals": true
}
}
}
4 changes: 2 additions & 2 deletions .github/codeql/config.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
paths:
- src
paths:
- src
9 changes: 0 additions & 9 deletions .github/dependabot.yml

This file was deleted.

4 changes: 4 additions & 0 deletions .github/renovate.json5
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
$schema: 'https://docs.renovatebot.com/renovate-schema.json',
extends: ['local>SpotOnInc/renovate-config']
}
2 changes: 1 addition & 1 deletion .github/workflows/automerge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: automerge
uses: "pascalgn/automerge-action@v0.12.0"
uses: "pascalgn/automerge-action@v0.16.3"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
MERGE_LABELS: "dependencies"
10 changes: 5 additions & 5 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
# We must fetch at least the immediate parents so that if this is
# a pull request then we can checkout the head.
Expand All @@ -43,19 +43,19 @@ jobs:

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
uses: github/codeql-action/init@23acc5c183826b7a8a97bce3cecc52db901f8251 # v3.25.10
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main
config-file: ./.github/codeql/config.yml

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1
uses: github/codeql-action/autobuild@23acc5c183826b7a8a97bce3cecc52db901f8251 # v3.25.10

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
Expand All @@ -69,4 +69,4 @@ jobs:
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
uses: github/codeql-action/analyze@23acc5c183826b7a8a97bce3cecc52db901f8251 # v3.25.10
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ jobs:
build: # make sure build/ci work properly
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- run: npm install
- run: npm run all
test: # make sure the action works on a clean machine without building
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- uses: ./
37 changes: 37 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
# Git style
- id: check-added-large-files
- id: check-merge-conflict
- id: check-vcs-permalinks
- id: forbid-new-submodules
- id: no-commit-to-branch

# Common errors
- id: end-of-file-fixer
- id: trailing-whitespace
args: [--markdown-linebreak-ext=md]
- id: check-yaml
- id: check-merge-conflict
- id: check-executables-have-shebangs

# Cross platform
- id: check-case-conflict
- id: mixed-line-ending
args: [--fix=lf]

# Security
- id: detect-aws-credentials
args: ['--allow-missing-credentials']
- id: detect-private-key


# JSON5 Linter
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.1.0
hooks:
- id: prettier
# https://prettier.io/docs/en/options.html#parser
files: '.json5$'
2 changes: 1 addition & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
dist/
lib/
node_modules/
node_modules/
2 changes: 1 addition & 1 deletion .prettierrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
"trailingComma": "none",
"bracketSpacing": false,
"arrowParens": "avoid"
}
}
1 change: 1 addition & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
MIT License

Copyright (c) 2022-2024 Maksym Vlasov
Copyright (c) 2020 Yuichi Tanaka

Permission is hereby granted, free of charge, to any person obtaining a copy
Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,19 @@ dive action is an action that allows developers who develop Docker image to run
```yaml
name: "Dive CI"

on: [push]
on: [pull_request]

jobs:
dive:
runs-on: ubuntu-latest
name: Analyze image efficiency
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Build image
run: docker build -t sample:latest .
- name: Dive
uses: yuichielectric/dive-action@0.0.4
uses: MaxymVlasov/dive-action@1.0.0
with:
image: "sample:latest"
config-file: ${{ github.workspace }}/.dive-ci.yml
Expand Down Expand Up @@ -131,9 +131,9 @@ Result:FAIL [Total:3] [Passed:2] [Failed:1] [Warn:0] [Skipped:0]
##[error]Process completed with exit code 1.
```

[release]: https://github.com/yuichielectric/dive-action/releases/latest
[release-badge]: https://img.shields.io/github/release/yuichielectric/dive-action.svg?logo=github&color=green
[release]: https://github.com/maxymvlasov/dive-action/releases/latest
[release-badge]: https://img.shields.io/github/release/maxymvlasov/dive-action.svg?logo=github&color=green
[marketplace]: https://github.com/marketplace/actions/dive-action
[marketplace-badge]: https://img.shields.io/badge/marketplace-dive--action-green?logo=github
[license]: https://github.com/yuichielectric/dive-action/blob/master/LICENSE
[license-badge]: https://img.shields.io/github/license/yuichielectric/dive-action.svg
[license]: https://github.com/maxymvlasov/dive-action/blob/master/LICENSE
[license-badge]: https://img.shields.io/github/license/maxymvlasov/dive-action.svg
6 changes: 3 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: "Dive Action"
name: "Dive Action v2"
description: "Run Dive to analyze the container image efficiency"
author: "@yuichielectric"
author: "@MaxymVlasov"
branding:
icon: "aperture"
color: "green"
Expand All @@ -16,5 +16,5 @@ inputs:
description: "GitHub Token to post PR comment"
required: true
runs:
using: "node12"
using: "node20"
main: "dist/index.js"
26 changes: 15 additions & 11 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.

14 changes: 7 additions & 7 deletions dist/sourcemap-register.js
Original file line number Diff line number Diff line change
Expand Up @@ -2386,7 +2386,7 @@ IndexedSourceMapConsumer.prototype.sourceContentFor =
* and an object is returned with the following properties:
*
* - line: The line number in the generated source, or null. The
* line number is 1-based.
* line number is 1-based.
* - column: The column number in the generated source, or null.
* The column number is 0-based.
*/
Expand Down Expand Up @@ -3871,7 +3871,7 @@ module.exports = require("path");
/************************************************************************/
/******/ // The module cache
/******/ var __webpack_module_cache__ = {};
/******/
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/ // Check if module is in cache
Expand All @@ -3884,7 +3884,7 @@ module.exports = require("path");
/******/ // no module.loaded needed
/******/ exports: {}
/******/ };
/******/
/******/
/******/ // Execute the module function
/******/ var threw = true;
/******/ try {
Expand All @@ -3893,18 +3893,18 @@ module.exports = require("path");
/******/ } finally {
/******/ if(threw) delete __webpack_module_cache__[moduleId];
/******/ }
/******/
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/************************************************************************/
/******/ /* webpack/runtime/compat */
/******/
/******/
/******/ __webpack_require__.ab = __dirname + "/";/************************************************************************/
/******/ // module exports must be returned from runtime so entry inlining is disabled
/******/ // startup
/******/ // Load entry module and return exports
/******/ return __webpack_require__(645);
/******/ })()
;
;
14 changes: 9 additions & 5 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function format(output: string): string {
ret.push('| Count | Wasted Space | File Paht |')
ret.push('|---|---|---|')
} else {
// https://github.com/wagoodman/dive/blob/master/runtime/ci/evaluator.go#L140
// https://github.com/wagoodman/dive/blob/v0.12.0/runtime/ci/evaluator.go#L138
ret.push(
`| ${line.slice(0, 5)} | ${line.slice(7, 19)} | ${line.slice(21)} |`
)
Expand All @@ -48,14 +48,14 @@ async function run(): Promise<void> {
const image = core.getInput('image')
const configFile = core.getInput('config-file')

const diveImage = 'wagoodman/dive:v0.9'
const diveImage = 'wagoodman/dive:v0.12'
await exec.exec('docker', ['pull', diveImage])

const commandOptions = [
'-e',
'CI=true',
'-e',
'DOCKER_API_VERSION=1.37',
'DOCKER_API_VERSION=1.45',
'--rm',
'-v',
'/var/run/docker.sock:/var/run/docker.sock'
Expand All @@ -65,12 +65,16 @@ async function run(): Promise<void> {
commandOptions.push(
'--mount',
`type=bind,source=${configFile},target=/.dive-ci`,
'--ci-config',
'/.dive-ci'
)
}

const parameters = ['run', ...commandOptions, diveImage, image]
if (fs.existsSync(configFile)) {
parameters.push(
'--ci-config',
'/.dive-ci'
)
}
let output = ''
const execOptions = {
ignoreReturnCode: true,
Expand Down