Skip to content
This repository was archived by the owner on Dec 16, 2022. It is now read-only.

Commit 6dbaf6b

Browse files
author
Paulo Gomes
committed
Run tests using key in memory
Signed-off-by: Paulo Gomes <[email protected]>
1 parent 74493ec commit 6dbaf6b

File tree

3 files changed

+84
-12
lines changed

3 files changed

+84
-12
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This Dockerfile tests the hack/Makefile output against git2go.
22
ARG BASE_VARIANT=alpine
3-
ARG GO_VERSION=1.17.6
3+
ARG GO_VERSION=1.17
44
ARG XX_VERSION=1.1.0
55

66
FROM --platform=$BUILDPLATFORM tonistiigi/xx:${XX_VERSION} AS xx

Dockerfile.test

Lines changed: 81 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,102 @@
1+
# This Dockerfile tests the hack/Makefile output against git2go.
12
ARG BASE_VARIANT=alpine
23
ARG GO_VERSION=1.17
34
ARG XX_VERSION=1.1.0
45

5-
ARG LIBGIT2_IMG
6-
ARG LIBGIT2_TAG
6+
FROM --platform=$BUILDPLATFORM tonistiigi/xx:${XX_VERSION} AS xx
77

8-
FROM ${LIBGIT2_IMG}:${LIBGIT2_TAG} AS build-deps
8+
FROM --platform=$BUILDPLATFORM ${BASE_VARIANT} AS build-base
9+
10+
RUN apk add --no-cache \
11+
bash \
12+
curl \
13+
build-base \
14+
linux-headers \
15+
perl \
16+
cmake \
17+
pkgconfig \
18+
gcc \
19+
musl-dev \
20+
clang \
21+
lld
922

10-
FROM --platform=$BUILDPLATFORM tonistiigi/xx:${XX_VERSION} AS xx
23+
COPY --from=xx / /
24+
25+
FROM build-base AS build-cross
26+
27+
ARG TARGETPLATFORM
28+
29+
RUN xx-apk add --no-cache \
30+
build-base \
31+
pkgconfig \
32+
gcc \
33+
musl-dev \
34+
clang \
35+
lld \
36+
llvm \
37+
linux-headers
38+
39+
WORKDIR /build
40+
COPY hack/static.sh .
41+
42+
ENV CC=xx-clang
43+
ENV CXX=xx-clang++
44+
45+
RUN CHOST=$(xx-clang --print-target-triple) \
46+
./static.sh build_libz
47+
48+
RUN CHOST=$(xx-clang --print-target-triple) \
49+
./static.sh build_openssl
50+
51+
RUN export LIBRARY_PATH="/usr/local/$(xx-info triple)/lib:/usr/local/$(xx-info triple)/lib64:${LIBRARY_PATH}" && \
52+
export PKG_CONFIG_PATH="/usr/local/$(xx-info triple)/lib/pkgconfig:/usr/local/$(xx-info triple)/lib64/pkgconfig" && \
53+
export OPENSSL_ROOT_DIR="/usr/local/$(xx-info triple)" && \
54+
export OPENSSL_CRYPTO_LIBRARY="/usr/local/$(xx-info triple)/lib64" && \
55+
export OPENSSL_INCLUDE_DIR="/usr/local/$(xx-info triple)/include/openssl"
56+
57+
RUN ./static.sh build_libssh2
58+
RUN ./static.sh build_libgit2
59+
60+
61+
# trimmed removes all non necessary files (i.e. openssl binary).
62+
FROM build-cross AS trimmed
63+
64+
ARG TARGETPLATFORM
65+
RUN mkdir -p /trimmed/usr/local/$(xx-info triple)/ && \
66+
mkdir -p /trimmed/usr/local/$(xx-info triple)/share
67+
68+
RUN cp -r /usr/local/$(xx-info triple)/lib/ /trimmed/usr/local/$(xx-info triple)/ && \
69+
cp -r /usr/local/$(xx-info triple)/lib64/ /trimmed/usr/local/$(xx-info triple)/ | true && \
70+
cp -r /usr/local/$(xx-info triple)/include/ /trimmed/usr/local/$(xx-info triple)/ && \
71+
cp -r /usr/local/$(xx-info triple)/share/doc/ /trimmed/usr/local/$(xx-info triple)/share/
72+
73+
FROM scratch as libs-arm64
74+
COPY --from=trimmed /trimmed/ /
75+
76+
FROM scratch as libs-amd64
77+
COPY --from=trimmed /trimmed/ /
78+
79+
FROM scratch as libs-armv7
80+
COPY --from=trimmed /trimmed/ /
81+
82+
FROM libs-$TARGETARCH$TARGETVARIANT as libs
83+
84+
# Everything above this line is a copy from Dockefile.
1185

1286
FROM --platform=$BUILDPLATFORM golang:${GO_VERSION}-${BASE_VARIANT} as gostable
1387

1488
FROM gostable AS go-linux
1589

1690
# Build-base consists of build platform dependencies and xx.
1791
# These will be used at current arch to yield execute the cross compilations.
18-
FROM go-${TARGETOS} AS build-base
92+
FROM go-${TARGETOS} AS go-base
1993

2094
RUN apk add clang lld pkgconfig
2195

2296
COPY --from=xx / /
2397

2498
# build-go-mod can still be cached at build platform architecture.
25-
FROM build-base as build-go-mod
99+
FROM go-base as build-go-mod
26100

27101
WORKDIR /root/smoketest
28102
COPY tests/smoketest/go.mod .
@@ -42,7 +116,7 @@ RUN xx-apk add musl-dev gcc clang lld
42116
WORKDIR /root/smoketest
43117

44118
COPY tests/smoketest/main.go .
45-
COPY --from=build-deps /usr/local/ /usr/local/
119+
COPY --from=libs /usr/local/ /usr/local/
46120

47121
ENV CGO_ENABLED=1
48122
RUN export LIBRARY_PATH="/usr/local/$(xx-info triple):/usr/local/$(xx-info triple)/lib64" && \

tests/smoketest/main.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,7 @@ func main() {
8080
FetchOptions: git2go.FetchOptions{
8181
RemoteCallbacks: git2go.RemoteCallbacks{
8282
CredentialsCallback: func(url string, username string, allowedTypes git2go.CredentialType) (*git2go.Credential, error) {
83-
return git2go.NewCredentialSSHKeyFromMemory("git",
84-
string(rsa.PublicKey), string(rsa.PrivateKey), "")
83+
return git2go.NewCredentialSSHKeyFromMemory("git", string(rsa.PublicKey), string(rsa.PrivateKey), "")
8584
},
8685
CertificateCheckCallback: knownHostsCallback(u.Host, knownHosts),
8786
},
@@ -100,8 +99,7 @@ func main() {
10099
FetchOptions: git2go.FetchOptions{
101100
RemoteCallbacks: git2go.RemoteCallbacks{
102101
CredentialsCallback: func(url string, username string, allowedTypes git2go.CredentialType) (*git2go.Credential, error) {
103-
return git2go.NewCredentialSSHKeyFromMemory("git",
104-
string(ed25519.PublicKey), string(ed25519.PrivateKey), "")
102+
return git2go.NewCredentialSSHKeyFromMemory("git", string(ed25519.PublicKey), string(ed25519.PrivateKey), "")
105103
},
106104
CertificateCheckCallback: knownHostsCallback(u.Host, knownHosts),
107105
},

0 commit comments

Comments
 (0)