From 7429f6707739419cd24ff9dc98e26033281453a3 Mon Sep 17 00:00:00 2001 From: Nova Kwok Date: Sun, 29 Dec 2024 11:55:25 +0800 Subject: [PATCH] install libvips in ci runtime (#370) * install libvips in ci runtime * Run CI on every PR * CI test in Docker * Update Dockerfile.CI --- .dockerignore | 4 +--- .github/workflows/CI.yaml | 41 +++++++++------------------------------ Dockerfile.CI | 11 +++++++++++ 3 files changed, 21 insertions(+), 35 deletions(-) create mode 100644 Dockerfile.CI diff --git a/.dockerignore b/.dockerignore index 86fab1489..30b551f9f 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,10 +1,8 @@ .github/* exhaust/* -pics/* remote-raw/* scripts/* .git .dockerignore README.md -LICENSE -Makefile \ No newline at end of file +LICENSE \ No newline at end of file diff --git a/.github/workflows/CI.yaml b/.github/workflows/CI.yaml index 29b74230b..11dc4e03c 100644 --- a/.github/workflows/CI.yaml +++ b/.github/workflows/CI.yaml @@ -1,35 +1,14 @@ name: CI check on every PR on: pull_request: - branches: - - master paths-ignore: - '**.md' - 'Makefile' - 'config.json' jobs: - ci: - name: CI check on every push and PR - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Install Go - uses: actions/setup-go@v5 - with: - go-version: '1.23' - - - name: Setup necessary packages - run: | - sudo apt update && sudo apt install libvips-dev -y - - - name: run test cases - run: make && make test - image-test: - name: Check for image build and CVE + name: Check for image build, testing and CVE runs-on: ubuntu-latest permissions: pull-requests: write @@ -42,15 +21,16 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - - name: Cache Docker layers - uses: actions/cache@v2 + - name: Make test + uses: docker/build-push-action@v3 with: - path: /tmp/.buildx-cache - key: ${{ runner.os }}-buildx-${{ github.sha }} - restore-keys: | - ${{ runner.os }}-buildx- + context: . + file: ./Dockerfile.CI + load: true + tags: | + ghcr.io/${{ github.event.repository.full_name }}:latest - - name: Build and load image + - name: Build image test uses: docker/build-push-action@v3 with: context: . @@ -58,9 +38,6 @@ jobs: tags: | ghcr.io/${{ github.event.repository.full_name }}:latest - cache-from: type=local,src=/tmp/.buildx-cache - cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - - name: Install trivy run: | wget -qO - https://aquasecurity.github.io/trivy-repo/deb/public.key | sudo apt-key add - diff --git a/Dockerfile.CI b/Dockerfile.CI new file mode 100644 index 000000000..8c74f0e39 --- /dev/null +++ b/Dockerfile.CI @@ -0,0 +1,11 @@ +FROM golang:1.23-bookworm as builder + +ARG IMG_PATH=/opt/pics +ARG EXHAUST_PATH=/opt/exhaust +RUN apt update && apt install --no-install-recommends libvips-dev -y && mkdir /build +COPY go.mod /build +RUN cd /build && go mod download + +COPY . /build + +RUN cd /build && make && make test \ No newline at end of file