-
Notifications
You must be signed in to change notification settings - Fork 137
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: using docker to execute CI tests on Github actions to preve…
…nt environmental breaking changes (#98)
- Loading branch information
Showing
8 changed files
with
167 additions
and
124 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
name: Run GoTest | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
push: | ||
branches: | ||
- main | ||
|
||
concurrency: | ||
group: test-${{ github.head_ref || github.run_id }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
test: | ||
name: Test | ||
runs-on: ${{ matrix.arch == 'amd64' && 'ubuntu-latest' || 'arm64_runner' }} | ||
strategy: | ||
matrix: | ||
arch: [amd64, arm64] | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Build and run tests | ||
run: | | ||
if [ "${{ matrix.arch }}" == "amd64" ]; then | ||
docker build -t test -f docker/amd64-test/dockerfile . | ||
docker run --rm test | ||
elif [ "${{ matrix.arch }}" == "arm64" ]; then | ||
docker build -t test -f docker/arm64-test/dockerfile . | ||
docker run --rm test | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
FROM golang:1.20.6 AS builder | ||
|
||
COPY . /app | ||
WORKDIR /app | ||
|
||
# if you located in China, you can use aliyun mirror to speed up | ||
# && echo "deb http://mirrors.aliyun.com/debian testing main" > /etc/apt/sources.list | ||
|
||
# install dependencies and build binary | ||
RUN apt-get update && apt-get install -y pkg-config gcc libseccomp-dev && go mod tidy && bash ./build/build_amd64.sh | ||
|
||
FROM python:3.10-slim-bookworm as tester | ||
|
||
# if you located in China, you can use aliyun mirror to speed up | ||
# && echo "deb http://mirrors.aliyun.com/debian testing main" > /etc/apt/sources.list | ||
|
||
# install system dependencies | ||
RUN echo "deb http://deb.debian.org/debian testing main" > /etc/apt/sources.list \ | ||
&& apt-get update \ | ||
&& apt-get install -y --no-install-recommends \ | ||
pkg-config \ | ||
libseccomp-dev \ | ||
wget \ | ||
curl \ | ||
xz-utils \ | ||
zlib1g=1:1.3.dfsg+really1.3.1-1 \ | ||
expat=2.6.3-1 \ | ||
perl=5.38.2-5 \ | ||
libsqlite3-0=3.46.0-1 \ | ||
&& apt-get clean \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
# workdir | ||
WORKDIR /app | ||
|
||
# checkout | ||
COPY . /app | ||
|
||
# copy binary and env from builder | ||
COPY --from=builder /app/internal/core/runner/python/python.so /app/internal/core/runner/python/python.so | ||
COPY --from=builder /app/internal/core/runner/nodejs/nodejs.so /app/internal/core/runner/nodejs/nodejs.so | ||
|
||
# copy test config file | ||
COPY conf/config.yaml /conf/config.yaml | ||
# copy python dependencies | ||
COPY dependencies/python-requirements.txt /dependencies/python-requirements.txt | ||
|
||
# install python dependencies | ||
RUN pip3 install --no-cache-dir httpx==0.27.2 requests==2.32.3 jinja2==3.0.3 PySocks httpx[socks] | ||
|
||
# install node | ||
RUN wget -O /opt/node-v20.11.1-linux-x64.tar.xz https://npmmirror.com/mirrors/node/v20.11.1/node-v20.11.1-linux-x64.tar.xz \ | ||
&& tar -xvf /opt/node-v20.11.1-linux-x64.tar.xz -C /opt \ | ||
&& ln -s /opt/node-v20.11.1-linux-x64/bin/node /usr/local/bin/node \ | ||
&& rm -f /opt/node-v20.11.1-linux-x64.tar.xz | ||
|
||
# install golang 1.20.6 | ||
RUN wget https://golang.org/dl/go1.20.6.linux-amd64.tar.gz \ | ||
&& tar -C /usr/local -xzf go1.20.6.linux-amd64.tar.gz \ | ||
&& ln -s /usr/local/go/bin/go /usr/local/bin/go \ | ||
&& rm -f go1.20.6.linux-amd64.tar.gz | ||
|
||
# run test | ||
RUN go test -timeout 120s -v ./tests/integration_tests/... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
FROM golang:1.20.6 AS builder | ||
|
||
COPY . /app | ||
WORKDIR /app | ||
|
||
# if you located in China, you can use aliyun mirror to speed up | ||
# && echo "deb http://mirrors.aliyun.com/debian testing main" > /etc/apt/sources.list | ||
|
||
# install dependencies and build binary | ||
RUN apt-get update && apt-get install -y pkg-config gcc libseccomp-dev && go mod tidy && bash ./build/build_arm64.sh | ||
|
||
FROM python:3.10-slim-bookworm as tester | ||
|
||
# if you located in China, you can use aliyun mirror to speed up | ||
# && echo "deb http://mirrors.aliyun.com/debian testing main" > /etc/apt/sources.list | ||
|
||
# install system dependencies | ||
RUN echo "deb http://deb.debian.org/debian testing main" > /etc/apt/sources.list \ | ||
&& apt-get update \ | ||
&& apt-get install -y --no-install-recommends \ | ||
pkg-config \ | ||
libseccomp-dev \ | ||
wget \ | ||
curl \ | ||
xz-utils \ | ||
zlib1g=1:1.3.dfsg+really1.3.1-1 \ | ||
expat=2.6.3-1 \ | ||
perl=5.38.2-5 \ | ||
libsqlite3-0=3.46.0-1 \ | ||
&& apt-get clean \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
# workdir | ||
WORKDIR /app | ||
|
||
# checkout | ||
COPY . /app | ||
|
||
# copy binary and env from builder | ||
COPY --from=builder /app/internal/core/runner/python/python.so /app/internal/core/runner/python/python.so | ||
COPY --from=builder /app/internal/core/runner/nodejs/nodejs.so /app/internal/core/runner/nodejs/nodejs.so | ||
|
||
# copy test config file | ||
COPY conf/config.yaml /conf/config.yaml | ||
# copy python dependencies | ||
COPY dependencies/python-requirements.txt /dependencies/python-requirements.txt | ||
|
||
# install python dependencies | ||
RUN pip3 install --no-cache-dir httpx==0.27.2 requests==2.32.3 jinja2==3.0.3 PySocks httpx[socks] | ||
|
||
# install node | ||
RUN wget -O /opt/node-v20.11.1-linux-arm64.tar.xz https://npmmirror.com/mirrors/node/v20.11.1/node-v20.11.1-linux-arm64.tar.xz \ | ||
&& tar -xvf /opt/node-v20.11.1-linux-arm64.tar.xz -C /opt \ | ||
&& ln -s /opt/node-v20.11.1-linux-arm64/bin/node /usr/local/bin/node \ | ||
&& rm -f /opt/node-v20.11.1-linux-arm64.tar.xz | ||
|
||
# install golang 1.20.6 | ||
RUN wget https://golang.org/dl/go1.20.6.linux-arm64.tar.gz \ | ||
&& tar -C /usr/local -xzf go1.20.6.linux-arm64.tar.gz \ | ||
&& ln -s /usr/local/go/bin/go /usr/local/bin/go \ | ||
&& rm -f go1.20.6.linux-arm64.tar.gz | ||
|
||
# run test | ||
RUN go test -timeout 120s -v ./tests/integration_tests/... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters