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

Add Earthly #4

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft
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
39 changes: 31 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,40 @@ 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
- 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: |
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 +ci

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
27 changes: 27 additions & 0 deletions Earthfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
VERSION 0.7
FROM 84codes/crystal:latest-ubuntu-22.04
WORKDIR /workdir

# 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
2 changes: 1 addition & 1 deletion spec/lucky_template_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading