From c9abdbf8dafaf2ae1354842429124e71f5075e24 Mon Sep 17 00:00:00 2001 From: fcd <1352288+femnad@users.noreply.github.com> Date: Sat, 9 Dec 2023 17:41:25 +0000 Subject: [PATCH 01/11] ci-wip --- Dockerfile.ubuntu | 5 +++++ contrib/test.yml | 22 ++++++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 Dockerfile.ubuntu create mode 100644 contrib/test.yml diff --git a/Dockerfile.ubuntu b/Dockerfile.ubuntu new file mode 100644 index 0000000..77d9fef --- /dev/null +++ b/Dockerfile.ubuntu @@ -0,0 +1,5 @@ +from ubuntu:mantic + +run apt update && apt install -y ca-certificates golang +run go install github.com/femnad/fup@latest +run ~/go/bin/fup -f diff --git a/contrib/test.yml b/contrib/test.yml new file mode 100644 index 0000000..9cd51fc --- /dev/null +++ b/contrib/test.yml @@ -0,0 +1,22 @@ +preflight: + - task: Enable Docker repo (Debian|Ubuntu) + when: is-debian is-ubuntu + unless: + stat: /etc/apt/sources.list.d/docker.list + steps: + - name: shell + shell: bash + cmd: | + set -euEo pipefail + mkdir -p /etc/apt/keyrings + curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg + chmod a+r /etc/apt/keyrings/docker.gpg + echo "deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu "$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" > /etc/apt/sources.list.d/docker.list + apt update + +packages: + debian|ubuntu: + - docker-buildx-plugin + - docker-ce + - docker-ce-cli + - docker-compose-plugin From 41b8837bf0d08425b042247fd8ec5f2f2a6d5b82 Mon Sep 17 00:00:00 2001 From: fcd <1352288+femnad@users.noreply.github.com> Date: Sat, 9 Dec 2023 17:47:08 +0000 Subject: [PATCH 02/11] test --- .github/workflows/test.yml | 4 ++++ Dockerfile.ubuntu | 2 +- contrib/test.yml | 3 +++ main.go | 2 +- 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a9eb85e..2519396 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -20,3 +20,7 @@ jobs: run: | go install python3 tests/test_archives.py + + - name: Run provisioning command + run: | + ~/go/bin/fup -f https://raw.githubusercontent.com/femnad/fup/ci-test/contrib/test.yml -b diff --git a/Dockerfile.ubuntu b/Dockerfile.ubuntu index 77d9fef..b4162a7 100644 --- a/Dockerfile.ubuntu +++ b/Dockerfile.ubuntu @@ -2,4 +2,4 @@ from ubuntu:mantic run apt update && apt install -y ca-certificates golang run go install github.com/femnad/fup@latest -run ~/go/bin/fup -f +run ~/go/bin/fup -f https://raw.githubusercontent.com/femnad/fup/ci-test/contrib/test.yml -b diff --git a/contrib/test.yml b/contrib/test.yml index 9cd51fc..d43a8bc 100644 --- a/contrib/test.yml +++ b/contrib/test.yml @@ -1,3 +1,6 @@ +settings: + extract_dir: ext + preflight: - task: Enable Docker repo (Debian|Ubuntu) when: is-debian is-ubuntu diff --git a/main.go b/main.go index 5e7451f..976725e 100644 --- a/main.go +++ b/main.go @@ -54,7 +54,7 @@ func main() { err = p.Apply() if err != nil { - fmt.Printf("Some provisioners had errors: %v", err) + fmt.Printf("Some provisioners had errors: %v\n", err) os.Exit(1) } } From b39d89101dd73fef9a75f33475d98235031fafc8 Mon Sep 17 00:00:00 2001 From: fcd <1352288+femnad@users.noreply.github.com> Date: Sat, 9 Dec 2023 17:50:03 +0000 Subject: [PATCH 03/11] sudo --- contrib/test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/contrib/test.yml b/contrib/test.yml index d43a8bc..1c24ff9 100644 --- a/contrib/test.yml +++ b/contrib/test.yml @@ -9,6 +9,7 @@ preflight: steps: - name: shell shell: bash + sudo: true cmd: | set -euEo pipefail mkdir -p /etc/apt/keyrings From cb1c45a596be5529a26fbd301f0568d70d51bc12 Mon Sep 17 00:00:00 2001 From: fcd <1352288+femnad@users.noreply.github.com> Date: Sat, 9 Dec 2023 17:53:23 +0000 Subject: [PATCH 04/11] no sudo --- Dockerfile.ubuntu | 2 +- contrib/test.yml | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/Dockerfile.ubuntu b/Dockerfile.ubuntu index b4162a7..f281fe6 100644 --- a/Dockerfile.ubuntu +++ b/Dockerfile.ubuntu @@ -2,4 +2,4 @@ from ubuntu:mantic run apt update && apt install -y ca-certificates golang run go install github.com/femnad/fup@latest -run ~/go/bin/fup -f https://raw.githubusercontent.com/femnad/fup/ci-test/contrib/test.yml -b +entrypoint ["/root/go/bin/fup", "-f", "https://raw.githubusercontent.com/femnad/fup/ci-test/contrib/test.yml", "-b"] diff --git a/contrib/test.yml b/contrib/test.yml index 1c24ff9..d43a8bc 100644 --- a/contrib/test.yml +++ b/contrib/test.yml @@ -9,7 +9,6 @@ preflight: steps: - name: shell shell: bash - sudo: true cmd: | set -euEo pipefail mkdir -p /etc/apt/keyrings From f0f9496b7e4cf152422bfdc5207b9d30f5755a0e Mon Sep 17 00:00:00 2001 From: fcd <1352288+femnad@users.noreply.github.com> Date: Sat, 9 Dec 2023 17:59:02 +0000 Subject: [PATCH 05/11] cont --- .github/workflows/test.yml | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2519396..9bf4244 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -21,6 +21,20 @@ jobs: go install python3 tests/test_archives.py - - name: Run provisioning command + container-test: + name: Run provisioning in a container + runs-on: ubuntu-latest + container: + image: ubuntu:mantic + steps: + - uses: actions/checkout@v4 + + - name: Setup container + run: | + apt update + apt install -y ca-certificates golang + go install + + - name: Provision run: | - ~/go/bin/fup -f https://raw.githubusercontent.com/femnad/fup/ci-test/contrib/test.yml -b + ~/go/bin/fup -f contrib/test.yml -b From 74014e844f0f494b93f0e158c8ce12991c6c5ef7 Mon Sep 17 00:00:00 2001 From: fcd <1352288+femnad@users.noreply.github.com> Date: Sat, 9 Dec 2023 18:00:18 +0000 Subject: [PATCH 06/11] fix --- .github/workflows/test.yml | 2 +- Dockerfile.ubuntu | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9bf4244..6eb34bb 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -32,7 +32,7 @@ jobs: - name: Setup container run: | apt update - apt install -y ca-certificates golang + apt install -y ca-certificates curl golang go install - name: Provision diff --git a/Dockerfile.ubuntu b/Dockerfile.ubuntu index f281fe6..1f7c637 100644 --- a/Dockerfile.ubuntu +++ b/Dockerfile.ubuntu @@ -1,5 +1,8 @@ from ubuntu:mantic run apt update && apt install -y ca-certificates golang -run go install github.com/femnad/fup@latest -entrypoint ["/root/go/bin/fup", "-f", "https://raw.githubusercontent.com/femnad/fup/ci-test/contrib/test.yml", "-b"] +workdir /root +run git clone https://github.com/femnad/fup.git +workdir /root/fup +run go install +entrypoint ["/root/go/bin/fup", "-f", "contrib/test.yml", "-b"] From 78c56675bb8b32ad8fa3c1ae301ff38e9efc4419 Mon Sep 17 00:00:00 2001 From: fcd <1352288+femnad@users.noreply.github.com> Date: Sat, 9 Dec 2023 18:04:18 +0000 Subject: [PATCH 07/11] fix --- .github/workflows/test.yml | 2 +- Dockerfile.ubuntu | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6eb34bb..5349ca2 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -32,7 +32,7 @@ jobs: - name: Setup container run: | apt update - apt install -y ca-certificates curl golang + apt install -y ca-certificates curl gnupg2 golang go install - name: Provision diff --git a/Dockerfile.ubuntu b/Dockerfile.ubuntu index 1f7c637..76d8ae2 100644 --- a/Dockerfile.ubuntu +++ b/Dockerfile.ubuntu @@ -1,6 +1,8 @@ from ubuntu:mantic -run apt update && apt install -y ca-certificates golang +arg branch=main + +run apt update && apt install -y ca-certificates git golang workdir /root run git clone https://github.com/femnad/fup.git workdir /root/fup From 122a43f9d408712ec88f4aaac29ff0256d5d234b Mon Sep 17 00:00:00 2001 From: fcd <1352288+femnad@users.noreply.github.com> Date: Sat, 9 Dec 2023 18:09:34 +0000 Subject: [PATCH 08/11] fix --- Dockerfile.ubuntu | 4 ++-- precheck/fact.go | 9 +++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Dockerfile.ubuntu b/Dockerfile.ubuntu index 76d8ae2..6b85910 100644 --- a/Dockerfile.ubuntu +++ b/Dockerfile.ubuntu @@ -2,9 +2,9 @@ from ubuntu:mantic arg branch=main -run apt update && apt install -y ca-certificates git golang +run apt update && apt install -y ca-certificates curl git gnupg2 golang workdir /root -run git clone https://github.com/femnad/fup.git +run git clone https://github.com/femnad/fup.git -b $branch workdir /root/fup run go install entrypoint ["/root/go/bin/fup", "-f", "contrib/test.yml", "-b"] diff --git a/precheck/fact.go b/precheck/fact.go index e7b4b07..7f00621 100644 --- a/precheck/fact.go +++ b/precheck/fact.go @@ -75,12 +75,17 @@ func neovimReady() (bool, error) { } func sshReady() (bool, error) { - resp, _ := marecmd.RunFormatError(marecmd.Input{Command: "ssh-add -l"}) - if resp.Code == 1 { + resp, err := marecmd.RunFormatError(marecmd.Input{Command: "ssh-add -l"}) + if err != nil { + internal.Log.Debugf("error checking ssh-add output: %v", err) return false, nil } output := strings.TrimSpace(resp.Stdout) + if output == "" { + return false, nil + } + for _, line := range strings.Split(output, "\n") { fields := strings.Split(line, " ") if len(fields) != 4 { From 8991ea7c7750ff3a2e7b10a8824a8f093e655c98 Mon Sep 17 00:00:00 2001 From: fcd <1352288+femnad@users.noreply.github.com> Date: Sat, 9 Dec 2023 18:12:27 +0000 Subject: [PATCH 09/11] name --- .github/workflows/test.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5349ca2..d842d9e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,3 +1,5 @@ +name: Run tests + on: pull_request: push: @@ -8,7 +10,7 @@ on: jobs: test: - name: Run tests + name: Run unit and integration tests runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 From 90bcf009c43f69e29ee60835f30a27c76132d8d1 Mon Sep 17 00:00:00 2001 From: fcd <1352288+femnad@users.noreply.github.com> Date: Sat, 9 Dec 2023 18:18:49 +0000 Subject: [PATCH 10/11] more config --- contrib/test.yml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/contrib/test.yml b/contrib/test.yml index d43a8bc..11f311e 100644 --- a/contrib/test.yml +++ b/contrib/test.yml @@ -1,5 +1,7 @@ settings: extract_dir: ext + versions: + chezmoi: 2.42.2 preflight: - task: Enable Docker repo (Debian|Ubuntu) @@ -23,3 +25,22 @@ packages: - docker-ce - docker-ce-cli - docker-compose-plugin + +archives: + - url: https://github.com/twpayne/chezmoi/releases/download/v${version}/chezmoi_${version}_linux_amd64.tar.gz + name: chezmoi + unless: + cmd: chezmoi --version + post: split 2 | cut 1 | cut -1 + +tasks: + - task: Clone chezmoi + unless: + stat: ~/.local/share/chezmoi + steps: + - name: git + repo: + name: https://gitlab.com/femnad/chezmoi.git + dir: ~/.local/share/chezmoi + - name: cmd + cmd: ~/bin/chezmoi apply --force From d4b66d045cb8181b9be602260f33071c06f4d3b9 Mon Sep 17 00:00:00 2001 From: fcd <1352288+femnad@users.noreply.github.com> Date: Sat, 9 Dec 2023 18:21:27 +0000 Subject: [PATCH 11/11] rm --- Dockerfile.ubuntu | 10 ---------- 1 file changed, 10 deletions(-) delete mode 100644 Dockerfile.ubuntu diff --git a/Dockerfile.ubuntu b/Dockerfile.ubuntu deleted file mode 100644 index 6b85910..0000000 --- a/Dockerfile.ubuntu +++ /dev/null @@ -1,10 +0,0 @@ -from ubuntu:mantic - -arg branch=main - -run apt update && apt install -y ca-certificates curl git gnupg2 golang -workdir /root -run git clone https://github.com/femnad/fup.git -b $branch -workdir /root/fup -run go install -entrypoint ["/root/go/bin/fup", "-f", "contrib/test.yml", "-b"]