From 15955a5cca6bf4c893eb18d9f437a4404503ff77 Mon Sep 17 00:00:00 2001 From: Michael Wagner Date: Wed, 27 Sep 2023 12:37:22 -0400 Subject: [PATCH 1/6] chore: add earthly to ci --- .github/workflows/ci.yml | 33 +++++++++++++++++++++++++-------- Earthfile | 16 ++++++++++++++++ 2 files changed, 41 insertions(+), 8 deletions(-) create mode 100644 Earthfile diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bebe694..90b78a6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,17 +8,34 @@ on: jobs: specs: - strategy: - fail-fast: false - matrix: - os: [ubuntu-latest, windows-latest] - crystal_version: [latest] - runs-on: ${{ matrix.os }} - continue-on-error: false + runs-on: ubuntu-latest + env: + FORCE_COLOR: 1 + steps: + - uses: earthly/actions-setup@v1 + with: + version: v0.7.8 + - uses: actions/checkout@v2 + - name: Put back the git branch into git (Earthly uses it for tagging) + run: | + branch="" + if [ -n "$GITHUB_HEAD_REF" ]; then + branch="$GITHUB_HEAD_REF" + else + branch="${GITHUB_REF##*/}" + fi + git checkout -b "$branch" || true + - name: Earthly version + run: earthly --version + - name: Run build + run: earthly +all + + windows-specs: + runs-on: windows-latest steps: - uses: actions/checkout@v3 - uses: crystal-lang/install-crystal@v1 with: - crystal: ${{ matrix.crystal_version }} + crystal: latest - name: Run tests run: crystal spec diff --git a/Earthfile b/Earthfile new file mode 100644 index 0000000..1c5cddf --- /dev/null +++ b/Earthfile @@ -0,0 +1,16 @@ +VERSION 0.7 +FROM crystallang/crystal:latest +WORKDIR /workdir + +all: + BUILD --platform=linux/amd64 --platform=linux/arm64 +test + +deps: + RUN apt-get update \ + && apt-get install -y gettext + COPY . ./ + RUN shards install + +test: + FROM +deps + RUN crystal spec From 34498d165b5c50f67f453bd50fcff6e276dcdbb4 Mon Sep 17 00:00:00 2001 From: Michael Wagner Date: Wed, 27 Sep 2023 12:40:02 -0400 Subject: [PATCH 2/6] fix: gh actions no qemu --- Earthfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Earthfile b/Earthfile index 1c5cddf..e363f57 100644 --- a/Earthfile +++ b/Earthfile @@ -3,7 +3,7 @@ FROM crystallang/crystal:latest WORKDIR /workdir all: - BUILD --platform=linux/amd64 --platform=linux/arm64 +test + BUILD +test deps: RUN apt-get update \ From 372b94e8dc1444bdbc14799388693e485fa3b40f Mon Sep 17 00:00:00 2001 From: Michael Wagner Date: Wed, 27 Sep 2023 12:45:45 -0400 Subject: [PATCH 3/6] chore: add qemu --- .github/workflows/ci.yml | 6 ++++++ Earthfile | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 90b78a6..a553897 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,6 +15,12 @@ jobs: - uses: earthly/actions-setup@v1 with: version: v0.7.8 + - name: Set up QEMU + id: qemu + uses: docker/setup-qemu-action@v1 + with: + image: tonistiigi/binfmt:latest + platforms: all - uses: actions/checkout@v2 - name: Put back the git branch into git (Earthly uses it for tagging) run: | diff --git a/Earthfile b/Earthfile index e363f57..651727a 100644 --- a/Earthfile +++ b/Earthfile @@ -3,7 +3,7 @@ FROM crystallang/crystal:latest WORKDIR /workdir all: - BUILD +test + BUILD --platform=linux/amd64--platform=linux/arm64 +test deps: RUN apt-get update \ From 4e49ec56933987f08bb15f2c3811b488a845f9d5 Mon Sep 17 00:00:00 2001 From: Michael Wagner Date: Wed, 27 Sep 2023 12:47:06 -0400 Subject: [PATCH 4/6] fix: typo --- Earthfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Earthfile b/Earthfile index 651727a..1c5cddf 100644 --- a/Earthfile +++ b/Earthfile @@ -3,7 +3,7 @@ FROM crystallang/crystal:latest WORKDIR /workdir all: - BUILD --platform=linux/amd64--platform=linux/arm64 +test + BUILD --platform=linux/amd64 --platform=linux/arm64 +test deps: RUN apt-get update \ From c5d2b4abda5dc150e64b62dd345d9fee56dc44ed Mon Sep 17 00:00:00 2001 From: Michael Wagner Date: Fri, 29 Sep 2023 18:24:33 -0400 Subject: [PATCH 5/6] fix: ameba --- Earthfile | 17 ++++++++++++++--- spec/lucky_template_spec.cr | 2 +- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/Earthfile b/Earthfile index 1c5cddf..96bef32 100644 --- a/Earthfile +++ b/Earthfile @@ -1,16 +1,27 @@ VERSION 0.7 -FROM crystallang/crystal:latest +FROM 84codes/crystal:latest-ubuntu-22.04 WORKDIR /workdir -all: - BUILD --platform=linux/amd64 --platform=linux/arm64 +test +# ci runs only in CI +ci: + BUILD +lint + BUILD --platform=linux/amd64 +test + BUILD --platform=linux/arm64 +test +# deps adds source code and builds project dependency graph deps: RUN apt-get update \ && apt-get install -y gettext COPY . ./ RUN shards install +# test executes project specs test: FROM +deps RUN crystal spec + +# lint executes ameba +lint: + FROM ghcr.io/crystal-ameba/ameba:1.5.0 + COPY . ./ + RUN ameba diff --git a/spec/lucky_template_spec.cr b/spec/lucky_template_spec.cr index aedd0fa..ed98f85 100644 --- a/spec/lucky_template_spec.cr +++ b/spec/lucky_template_spec.cr @@ -141,7 +141,7 @@ describe LuckyTemplate do end it "raises if folder is locked" do - folder = LuckyTemplate.write!(Path["."]) do |dir| + LuckyTemplate.write!(Path["."]) do |dir| expect_raises(LuckyTemplate::Error, "folder is locked") do LuckyTemplate.validate!(Path["."], dir) end From fff5b1c493e72dfdb68863d1c30c5f0096d82e50 Mon Sep 17 00:00:00 2001 From: Michael Wagner Date: Fri, 29 Sep 2023 18:25:44 -0400 Subject: [PATCH 6/6] chore: switch all to ci --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a553897..1e46ec4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -34,7 +34,7 @@ jobs: - name: Earthly version run: earthly --version - name: Run build - run: earthly +all + run: earthly +ci windows-specs: runs-on: windows-latest