mirror of
https://github.com/earthly/actions-setup.git
synced 2024-12-26 22:41:01 +08:00
extra testing
Signed-off-by: Alex Couture-Beil <alex@earthly.dev>
This commit is contained in:
parent
a32f779fcc
commit
6ca06ce14a
17
.github/workflows/test.yml
vendored
17
.github/workflows/test.yml
vendored
@ -5,13 +5,14 @@ on:
|
|||||||
branches:
|
branches:
|
||||||
- "main"
|
- "main"
|
||||||
- "releases/*"
|
- "releases/*"
|
||||||
|
- "acb/*"
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
unit:
|
unit:
|
||||||
name: Unit Test
|
name: earthly +all
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
platform: [ubuntu-latest, macos-latest, windows-latest]
|
platform: [ubuntu-latest]
|
||||||
runs-on: ${{ matrix.platform }}
|
runs-on: ${{ matrix.platform }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
@ -19,8 +20,11 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
cache: ${{ !env.ACT && 'npm' || '' }}
|
cache: ${{ !env.ACT && 'npm' || '' }}
|
||||||
node-version: "16.x"
|
node-version: "16.x"
|
||||||
- run: npm install
|
- uses: ./
|
||||||
- run: npm run test
|
- run: which earthly
|
||||||
|
- run: env
|
||||||
|
- run: earthly +all
|
||||||
|
# Below are tests specific to the github actions, which ensure the actions-setup code works with GHA
|
||||||
latest:
|
latest:
|
||||||
name: Test Latest Version Install
|
name: Test Latest Version Install
|
||||||
strategy:
|
strategy:
|
||||||
@ -37,6 +41,7 @@ jobs:
|
|||||||
- run: npm run package
|
- run: npm run package
|
||||||
- uses: ./
|
- uses: ./
|
||||||
- run: earthly --version
|
- run: earthly --version
|
||||||
|
- run: earthly --version | grep 'earthly\(\.exe\)\? version v'
|
||||||
specific:
|
specific:
|
||||||
name: Test Specific Version Install
|
name: Test Specific Version Install
|
||||||
strategy:
|
strategy:
|
||||||
@ -56,6 +61,7 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
version: 0.5.15
|
version: 0.5.15
|
||||||
- run: earthly --version
|
- run: earthly --version
|
||||||
|
- run: earthly --version | grep 'earthly\(\.exe\)\? version v0\.5\.15'
|
||||||
patch-range:
|
patch-range:
|
||||||
name: Test Patch Range Version Install
|
name: Test Patch Range Version Install
|
||||||
strategy:
|
strategy:
|
||||||
@ -74,6 +80,7 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
version: 0.6.*
|
version: 0.6.*
|
||||||
- run: earthly --version
|
- run: earthly --version
|
||||||
|
- run: earthly --version | grep 'earthly\(\.exe\)\? version v0\.6\.'
|
||||||
major-range:
|
major-range:
|
||||||
name: Test Patch Range Version Install
|
name: Test Patch Range Version Install
|
||||||
strategy:
|
strategy:
|
||||||
@ -91,4 +98,4 @@ jobs:
|
|||||||
- uses: ./
|
- uses: ./
|
||||||
with:
|
with:
|
||||||
version: ^0.6.1
|
version: ^0.6.1
|
||||||
- run: earthly --version
|
- run: earthly --version | grep 'earthly\(\.exe\)\? version v0\.6\.'
|
||||||
|
54
Earthfile
54
Earthfile
@ -1,3 +1,5 @@
|
|||||||
|
VERSION 0.6
|
||||||
|
|
||||||
npm-base:
|
npm-base:
|
||||||
FROM alpine:3.13.5
|
FROM alpine:3.13.5
|
||||||
RUN apk add --update nodejs npm
|
RUN apk add --update nodejs npm
|
||||||
@ -35,7 +37,59 @@ test:
|
|||||||
COPY jest.config.js .
|
COPY jest.config.js .
|
||||||
RUN npm test
|
RUN npm test
|
||||||
|
|
||||||
|
test-run:
|
||||||
|
FROM +npm-base
|
||||||
|
COPY --dir +compile/dist .
|
||||||
|
ENV RUNNER_TOOL_CACHE=/tmp/cache-dir
|
||||||
|
RUN node dist/setup/index.js | tee output
|
||||||
|
RUN ! grep 'Found tool in cache' output
|
||||||
|
RUN cat output | grep '^::add-path::' | sed 's/::add-path:://g' > earthly-path
|
||||||
|
RUN test "$(cat earthly-path)" = "/root/.earthly/bin"
|
||||||
|
RUN export PATH="$(cat earthly-path):$PATH" && earthly --version | grep '^earthly version v.*linux/amd64; Linux'
|
||||||
|
|
||||||
|
# validate cache was used
|
||||||
|
RUN node dist/setup/index.js | tee output2
|
||||||
|
RUN grep 'Found tool in cache' output2
|
||||||
|
|
||||||
|
lint-newline:
|
||||||
|
FROM alpine:3.15
|
||||||
|
WORKDIR /everything
|
||||||
|
COPY . .
|
||||||
|
# test that line endings are unix-style
|
||||||
|
RUN set -e; \
|
||||||
|
code=0; \
|
||||||
|
for f in $(find . -type f \( -iname '*.ts' -o -iname 'Earthfile' \) | grep -v node_modules); do \
|
||||||
|
if ! dos2unix < "$f" | cmp - "$f"; then \
|
||||||
|
echo "$f contains windows-style newlines and must be converted to unix-style (use dos2unix to fix)"; \
|
||||||
|
code=1; \
|
||||||
|
fi; \
|
||||||
|
done; \
|
||||||
|
exit $code
|
||||||
|
# test file ends with a single newline
|
||||||
|
RUN set -e; \
|
||||||
|
code=0; \
|
||||||
|
for f in $(find . -type f \( -iname '*.ts' -o -iname 'Earthfile' \) | grep -v node_modules); do \
|
||||||
|
if [ "$(tail -c 1 $f)" != "$(printf '\n')" ]; then \
|
||||||
|
echo "$f does not end with a newline"; \
|
||||||
|
code=1; \
|
||||||
|
fi; \
|
||||||
|
done; \
|
||||||
|
exit $code
|
||||||
|
# check for files with trailing newlines
|
||||||
|
RUN set -e; \
|
||||||
|
code=0; \
|
||||||
|
for f in $(find . -type f \( -iname '*.ts' -o -iname 'Earthfile' \) | grep -v node_modules); do \
|
||||||
|
if [ "$(tail -c 2 $f)" == "$(printf '\n\n')" ]; then \
|
||||||
|
echo "$f has trailing newlines"; \
|
||||||
|
code=1; \
|
||||||
|
fi; \
|
||||||
|
done; \
|
||||||
|
exit $code
|
||||||
|
|
||||||
|
|
||||||
all:
|
all:
|
||||||
BUILD +lint
|
BUILD +lint
|
||||||
|
BUILD +lint-newline
|
||||||
BUILD +compile
|
BUILD +compile
|
||||||
BUILD +test
|
BUILD +test
|
||||||
|
BUILD +test-run
|
||||||
|
Loading…
x
Reference in New Issue
Block a user