...
1name: Basic e2e test
2
3on:
4 pull_request:
5 branches: ['main']
6
7jobs:
8 e2e:
9 strategy:
10 fail-fast: false
11 matrix:
12 platform:
13 - ubuntu-latest
14 - windows-latest
15 name: e2e ${{ matrix.platform }}
16 runs-on: ${{ matrix.platform }}
17
18 steps:
19 - uses: actions/checkout@v3
20 - uses: actions/setup-go@v4
21 with:
22 go-version: 1.19
23 check-latest: true
24
25 - name: crane append to an image, set the entrypoint, run it locally, roundtrip it
26 shell: bash
27 run: |
28 set -euxo pipefail
29
30 # Setup local registry
31 go run ./cmd/registry &
32
33 base=alpine
34 platform=linux/amd64
35 if [[ "${{ matrix.platform }}" == "windows-latest" ]]; then
36 base=mcr.microsoft.com/windows/nanoserver:ltsc2022
37 platform=windows/amd64
38 fi
39
40 CGO_ENABLED=0 go build -o app/crane ./cmd/crane
41 tar cvf crane.tar app
42
43 # This prevents Bash for Windows from mangling path names.
44 # It shouldn't be necessary in general unless you're using Bash for
45 # Windows.
46 export MSYS_NO_PATHCONV=1
47
48 img=$(./app/crane mutate \
49 --entrypoint=/app/crane,version \
50 $(./app/crane append \
51 --platform ${platform} \
52 --base ${base} \
53 --new_tag localhost:1338/append-test \
54 --new_layer crane.tar))
55
56 # Run the image with and without args.
57 docker run $img
58 docker run $img --help
59
60 # Make sure we can roundtrip it through pull/push
61 layout=$(mktemp -d)
62 dst=localhost:1338/roundtrip-test
63
64 ./app/crane pull --format=oci $img $layout
65 ./app/crane push --image-refs=foo.images $layout $dst
66 diff <(./app/crane manifest $img) <(./app/crane manifest $(cat foo.images))
67
68 # Make sure we can roundtrip an index (distroless).
69 distroless=$(mktemp -d)
70 remote="gcr.io/distroless/static"
71 local="localhost:1338/distroless:static"
72
73 ./app/crane pull --format=oci $remote $distroless
74 ./app/crane push $distroless $local
75 diff <(./app/crane manifest $remote) <(./app/crane manifest $local)
76
77 # And that it works for a single platform (pulling from what we just pushed).
78 distroless=$(mktemp -d)
79 remote="$local"
80 local="localhost:1338/distroless/platform:static"
81
82 ./app/crane pull --platform=linux/arm64 --format=oci $remote $distroless
83 ./app/crane push $distroless $local
84 diff <(./app/crane manifest --platform linux/arm64 $remote) <(./app/crane manifest $local)
85
86 - name: crane pull image, and export it from stdin to filesystem tar to stdout
87 shell: bash
88 run: |
89 set -euxo pipefail
90
91 ./app/crane pull ubuntu ubuntu.tar
92 ./app/crane export - - < ubuntu.tar > filesystem.tar
93 ls -la *.tar
94
View as plain text