Skip to content

Commit

Permalink
Reserve earthly for integration only (phoenixframework#4964)
Browse files Browse the repository at this point in the history
  • Loading branch information
josevalim authored Sep 21, 2022
1 parent 65bbe69 commit 6d7bcee
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 73 deletions.
118 changes: 91 additions & 27 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,103 @@ permissions:
contents: read

jobs:
test-elixir:
runs-on: ubuntu-latest
mix_test:
name: mix test (OTP ${{matrix.otp}} | Elixir ${{matrix.elixir}})

env:
FORCE_COLOR: 1
MIX_ENV: test

strategy:
fail-fast: false
max-parallel: 1
matrix:
include:
- elixir: 1.11.4
otp: 23.3.4
run_installer_tests: 0
- elixir: 1.13.3
- elixir: 1.12.0
otp: 22.3

- elixir: 1.14.0
otp: 24.3.4
run_installer_tests: 1
lint: lint

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Download released earth
run: "sudo /bin/sh -c 'wget https://github.com/earthly/earthly/releases/download/v0.5.16/earthly-linux-amd64 -O /usr/local/bin/earthly && chmod +x /usr/local/bin/earthly'"
- name: Execute tests
run: earthly --build-arg ELIXIR=${{ matrix.elixir }} --build-arg OTP=${{ matrix.otp }} --build-arg RUN_INSTALLER_TESTS=${{ matrix.run_installer_tests }} +test
- name: Checkout
uses: actions/checkout@v2

- name: Set up Elixir
uses: erlef/setup-beam@v1
with:
elixir-version: ${{ matrix.elixir }}
otp-version: ${{ matrix.otp }}

- name: Restore deps and _build cache
uses: actions/cache@v2
with:
path: |
deps
_build
key: deps-${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-${{ hashFiles('**/mix.lock') }}
restore-keys: |
deps-${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}
- name: Install dependencies
run: mix deps.get --only test

- name: Remove compiled application files
run: mix clean

- name: Compile dependencies
run: mix compile
if: ${{ !matrix.lint }}

- name: Compile & lint dependencies
run: mix compile --warnings-as-errors
if: ${{ matrix.lint }}

- name: Run tests
run: mix test

- name: Run installer test
run:
- cd installer
- mix test
if: ${{ matrix.installer }}

npm_test:
name: npm test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Restore deps and _build cache
uses: actions/cache@v2
with:
path: |
deps
_build
key: deps-${{ runner.os }}-npm-${{ hashFiles('**/mix.lock') }}
restore-keys: |
deps-${{ runner.os }}-npm
- name: Set up Node.js 12.x
uses: actions/setup-node@v1
with:
node-version: 12.x

- name: Restore npm cache
uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: npm install and test
run: |
cd assets
npm install
npm test
integration-test-elixir:
runs-on: ubuntu-latest
env:
Expand All @@ -35,22 +110,11 @@ jobs:
fail-fast: false
matrix:
include:
- elixir: 1.13.3
otp: 23.3.4
- elixir: 1.13.3
- elixir: 1.14.0
otp: 24.3.4
steps:
- uses: actions/checkout@v3
- name: Download released earth
run: "sudo /bin/sh -c 'wget https://github.com/earthly/earthly/releases/download/v0.5.16/earthly-linux-amd64 -O /usr/local/bin/earthly && chmod +x /usr/local/bin/earthly'"
- name: Execute tests
run: earthly -P --build-arg ELIXIR=${{ matrix.elixir }} --build-arg OTP=${{ matrix.otp }} +integration-test
npm_test:
name: npm
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Download released earth
run: "sudo /bin/sh -c 'wget https://github.com/earthly/earthly/releases/download/v0.5.16/earthly-linux-amd64 -O /usr/local/bin/earthly && chmod +x /usr/local/bin/earthly'"
- name: Execute tests
run: earthly --build-arg ELIXIR=1.13.3 --build-arg OTP=24.3.4 +npm
47 changes: 1 addition & 46 deletions Earthfile
Original file line number Diff line number Diff line change
@@ -1,32 +1,8 @@
all:
BUILD +all-test
BUILD +all-integration-test
BUILD +npm

all-test:
BUILD --build-arg ELIXIR=1.11.4 --build-arg OTP=23.3.4 +test
BUILD --build-arg ELIXIR=1.13.3 --build-arg OTP=24.3.4 --build-arg RUN_INSTALLER_TESTS=1 +test

test:
ARG RUN_INSTALLER_TESTS=0
FROM +test-setup
COPY --dir config installer ./
RUN MIX_ENV=test mix deps.compile
COPY --dir assets config installer lib integration_test priv test ./

# Run unit tests
RUN mix test

IF [ "$RUN_INSTALLER_TESTS" = "1" ]
WORKDIR /src/installer
RUN mix test
ELSE
RUN echo "Skipping installer tests"
END

all-integration-test:
BUILD --build-arg ELIXIR=1.13.3 --build-arg OTP=22.3.4 +integration-test
BUILD --build-arg ELIXIR=1.13.3 --build-arg OTP=24.3.4 +integration-test
BUILD --build-arg ELIXIR=1.14.0 --build-arg OTP=24.3.4 +integration-test

integration-test:
FROM +setup-base
Expand Down Expand Up @@ -84,31 +60,10 @@ integration-test:
mix test --include database
END

npm:
FROM node:12-alpine3.12
WORKDIR /src
RUN mkdir assets
# Copy package.json + lockfile separately to improve caching (JS changes don't trigger `npm install` anymore)
COPY assets/package* assets
WORKDIR assets
RUN npm install
COPY assets/ .
RUN npm test

setup-base:
ARG ELIXIR=1.13.3
ARG OTP=24.3.4
FROM hexpm/elixir:$ELIXIR-erlang-$OTP-alpine-3.16.0
RUN apk add --no-progress --update git build-base
ENV ELIXIR_ASSERT_TIMEOUT=10000
WORKDIR /src

test-setup:
FROM +setup-base
COPY mix.exs .
COPY mix.lock .
COPY .formatter.exs .
COPY package.json .
RUN mix local.rebar --force
RUN mix local.hex --force
RUN mix deps.get

0 comments on commit 6d7bcee

Please sign in to comment.