From 2754bd63e5993b4a4709f2f341980b6adeddca22 Mon Sep 17 00:00:00 2001 From: Jan Wagner Date: Thu, 4 Jan 2024 19:36:01 +0100 Subject: [PATCH 1/6] Adding installation of skopeo Since other platforms, beside Github Actions, can use Actions (see https://forgejo.org/docs/v1.21/user/actions/), it is not save to assume skopeo is installed by default. --- main.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/main.js b/main.js index 7b214bc..e41752d 100644 --- a/main.js +++ b/main.js @@ -16,9 +16,25 @@ function getImageTag(imageName, distribution) { } async function getImageName(distribution) { + const io = require('@actions/io') const tag = getImageTag("", distribution) for (const image of ["debian", "ubuntu"]) { try { + const skopeoPath = await io.which('skopeo', true) + if (!skopeoPath) { + core.startGroup("Install skopeo") + await exec.exec("sudo", [ + "apt-get", + "update" + ]) + await exec.exec("sudo", [ + "apt-get", + "-y", + "install", + "skopeo" + ]) + core.endGroup() + } core.startGroup("Get image name") await exec.exec("skopeo", [ "inspect", From 37027eb435b955a88cf410bfb7f272e74d84a854 Mon Sep 17 00:00:00 2001 From: Dawid Dziurla Date: Fri, 5 Jan 2024 18:50:29 +0100 Subject: [PATCH 2/6] main: move io requirement higher --- main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.js b/main.js index e41752d..e81086b 100644 --- a/main.js +++ b/main.js @@ -1,5 +1,6 @@ const core = require("@actions/core") const exec = require("@actions/exec") +const io = require('@actions/io') const firstline = require("firstline") const path = require("path") const fs = require("fs") @@ -16,7 +17,6 @@ function getImageTag(imageName, distribution) { } async function getImageName(distribution) { - const io = require('@actions/io') const tag = getImageTag("", distribution) for (const image of ["debian", "ubuntu"]) { try { From e4bbe94be9c3492104b004f5897f9e064602afb6 Mon Sep 17 00:00:00 2001 From: Jan Wagner Date: Fri, 5 Jan 2024 21:53:54 +0100 Subject: [PATCH 3/6] CI: Adding removal of skopeo --- .github/workflows/test.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2637e5f..ef5a77c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -54,6 +54,8 @@ jobs: uses: actions/checkout@v4 - name: Clone repo run: git clone --depth=1 ${{matrix.repo}} -b ${{matrix.ref}} ${{matrix.package}} + - name: Remove skopeo (for testing installation) + run: sudo rm -f $(which skopeo) - name: Test run uses: ./ with: From 8fe07bfb482bbbc395858f850ff00e40c67782f2 Mon Sep 17 00:00:00 2001 From: Dawid Dziurla Date: Sat, 6 Jan 2024 13:36:16 +0100 Subject: [PATCH 4/6] main: check for skopeo only once --- main.js | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/main.js b/main.js index e81086b..148781a 100644 --- a/main.js +++ b/main.js @@ -17,24 +17,24 @@ function getImageTag(imageName, distribution) { } async function getImageName(distribution) { + const skopeoPath = await io.which('skopeo', false) + if (!skopeoPath) { + core.startGroup("Install skopeo") + await exec.exec("sudo", [ + "apt-get", + "update" + ]) + await exec.exec("sudo", [ + "apt-get", + "-y", + "install", + "skopeo" + ]) + core.endGroup() + } const tag = getImageTag("", distribution) for (const image of ["debian", "ubuntu"]) { try { - const skopeoPath = await io.which('skopeo', true) - if (!skopeoPath) { - core.startGroup("Install skopeo") - await exec.exec("sudo", [ - "apt-get", - "update" - ]) - await exec.exec("sudo", [ - "apt-get", - "-y", - "install", - "skopeo" - ]) - core.endGroup() - } core.startGroup("Get image name") await exec.exec("skopeo", [ "inspect", From 59c99c08995299ca0c6e85e8b07bbe74ad537353 Mon Sep 17 00:00:00 2001 From: Dawid Dziurla Date: Sat, 6 Jan 2024 13:39:26 +0100 Subject: [PATCH 5/6] workflows: install skopeo only in one case no need to do test this for every case --- .github/workflows/test.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ef5a77c..549587b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -39,6 +39,7 @@ jobs: repo: https://github.com/dawidd6/deber.git ref: v1.0.0 lintian_opts: "-v" + install_skopeo: true - package: netcat-openbsd arch: arm64 repo: https://git.launchpad.net/ubuntu/+source/netcat-openbsd @@ -52,10 +53,14 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v4 + - name: Clone repo run: git clone --depth=1 ${{matrix.repo}} -b ${{matrix.ref}} ${{matrix.package}} + - name: Remove skopeo (for testing installation) - run: sudo rm -f $(which skopeo) + if: ${{matrix.install_skopeo}} + run: sudo rm -v $(which skopeo) + - name: Test run uses: ./ with: @@ -63,7 +68,8 @@ jobs: source_directory: ${{matrix.package}} artifacts_directory: artifacts lintian_opts: ${{matrix.lintian_opts}} - lintian_run: ${{matrix.lintian_run || false }} + lintian_run: ${{matrix.lintian_run || false}} + - name: Check files run: | ls -lh artifacts/${{matrix.package}}*.* From 627d37baff068a53b53ad9075f17fd7c4132a0c3 Mon Sep 17 00:00:00 2001 From: Dawid Dziurla Date: Sat, 6 Jan 2024 13:42:09 +0100 Subject: [PATCH 6/6] workflows: remove skopeo vi apt --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 549587b..8229413 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -59,7 +59,7 @@ jobs: - name: Remove skopeo (for testing installation) if: ${{matrix.install_skopeo}} - run: sudo rm -v $(which skopeo) + run: sudo apt-get remove -y skopeo - name: Test run uses: ./