From 3e65e1a029c44b33a77ca04724335ee3ecd30e67 Mon Sep 17 00:00:00 2001 From: Ruben ten Hove Date: Tue, 28 Jun 2022 15:59:56 +0000 Subject: fix test using test specific build --- .github/workflows/codeql-analysis.yaml | 30 -------------- .github/workflows/codeql-analysis.yml | 30 ++++++++++++++ .github/workflows/container.yaml | 68 ------------------------------ .github/workflows/container.yml | 75 ++++++++++++++++++++++++++++++++++ Dockerfile | 12 ++++-- 5 files changed, 113 insertions(+), 102 deletions(-) delete mode 100644 .github/workflows/codeql-analysis.yaml create mode 100644 .github/workflows/codeql-analysis.yml delete mode 100644 .github/workflows/container.yaml create mode 100644 .github/workflows/container.yml diff --git a/.github/workflows/codeql-analysis.yaml b/.github/workflows/codeql-analysis.yaml deleted file mode 100644 index c9efb296..00000000 --- a/.github/workflows/codeql-analysis.yaml +++ /dev/null @@ -1,30 +0,0 @@ -name: "CodeQL" - -on: - push: - branches: [stable, dev] - pull_request: - branches: [stable, dev] - -jobs: - codeql: - name: Analyze - runs-on: ubuntu-latest - container: # We use a previous image as it's expected to have all the dependencies - image: docker.io/aflplusplus/aflplusplus:dev - steps: - - name: Fix for using external repo in container build # https://github.com/actions/checkout/issues/760 - run: git config --global --add safe.directory /__w/AFLplusplus/AFLplusplus - - name: Checkout - uses: actions/checkout@v3 - - name: Initialize CodeQL - uses: github/codeql-action/init@v2 - with: - languages: cpp, python - - name: Build AFLplusplus # Rebuild because CodeQL needs to monitor the build process - env: - CC: gcc # These are symlinked to the version used in the container build - CXX: g++ - run: make -i distrib # Best effort using -i - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml new file mode 100644 index 00000000..ba6792b1 --- /dev/null +++ b/.github/workflows/codeql-analysis.yml @@ -0,0 +1,30 @@ +name: "CodeQL" + +on: + push: + branches: [stable, dev] + pull_request: + branches: [stable, dev] + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + container: # We use a previous image as it's expected to have all the dependencies + image: docker.io/aflplusplus/aflplusplus:dev + steps: + - name: Fix for using external repo in container build # https://github.com/actions/checkout/issues/760 + run: git config --global --add safe.directory /__w/AFLplusplus/AFLplusplus + - name: Checkout + uses: actions/checkout@v3 + - name: Initialize CodeQL + uses: github/codeql-action/init@v2 + with: + languages: cpp, python + - name: Build AFLplusplus # Rebuild because CodeQL needs to monitor the build process + env: + CC: gcc # These are symlinked to the version used in the container build + CXX: g++ + run: make -i distrib # Best effort using -i + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v2 diff --git a/.github/workflows/container.yaml b/.github/workflows/container.yaml deleted file mode 100644 index 81e2a3f8..00000000 --- a/.github/workflows/container.yaml +++ /dev/null @@ -1,68 +0,0 @@ -name: Container -on: - push: - branches: - - stable - - dev - tags: - - "*" - pull_request: - branches: - - dev # No need for stable-pull-request, as that equals dev-push - -jobs: - build-and-test-amd64: - name: Test amd64 image - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - name: Build amd64 - uses: docker/build-push-action@v3 - with: - context: . - tags: aflplusplus:amd64 - load: true - cache-to: type=gha,mode=max - - name: Test amd64 - run: docker run --rm aflplusplus:amd64 bash -c "apt-get update && apt-get install -y libcmocka-dev && make -i tests" - - push: - name: Push amd64 and arm64 images - runs-on: ubuntu-latest - needs: - - build-and-test-amd64 - if: ${{ github.event_name == 'push' && github.repository == 'AFLplusplus/AFLplusplus' }} - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - with: - platforms: arm64 - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - name: Login to docker.io - uses: docker/login-action@v2 - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_TOKEN }} - - name: Set tags to push - id: push-tags - run: | - PUSH_TAGS=docker.io/aflplusplus/aflplusplus:${GITHUB_REF_NAME} - if [ "${GITHUB_REF_NAME}" = "stable" ]; then - PUSH_TAGS=${PUSH_TAGS},docker.io/aflplusplus/aflplusplus:latest - fi - export PUSH_TAGS - echo "::set-output name=PUSH_TAGS::${PUSH_TAGS}" - - name: Push to docker.io registry - uses: docker/build-push-action@v3 - with: - context: . - platforms: linux/amd64,linux/arm64 - push: true - tags: ${{ steps.push-tags.outputs.PUSH_TAGS }} - cache-from: type=gha diff --git a/.github/workflows/container.yml b/.github/workflows/container.yml new file mode 100644 index 00000000..8836997d --- /dev/null +++ b/.github/workflows/container.yml @@ -0,0 +1,75 @@ +name: Container +on: + push: + branches: + - stable + - dev + tags: + - "*" + pull_request: + branches: + - dev # No need for stable-pull-request, as that equals dev-push + +jobs: + build-and-test-amd64: + name: Test amd64 image + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - name: Build amd64 + uses: docker/build-push-action@v3 + with: + context: . + tags: aflplusplus:test-amd64 + load: true + cache-to: type=gha,mode=max + build-args: | + TEST_BUILD=1 + - name: Test amd64 + run: > + docker run --rm aflplusplus:test-amd64 bash -c " + apt-get update && + apt-get install -y libcmocka-dev && + make -i tests + " + + push: + name: Push amd64 and arm64 images + runs-on: ubuntu-latest + needs: + - build-and-test-amd64 + if: ${{ github.event_name == 'push' && github.repository == 'AFLplusplus/AFLplusplus' }} + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + with: + platforms: arm64 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - name: Login to docker.io + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_TOKEN }} + - name: Set tags to push + id: push-tags + run: | + PUSH_TAGS=docker.io/aflplusplus/aflplusplus:${GITHUB_REF_NAME} + if [ "${GITHUB_REF_NAME}" = "stable" ]; then + PUSH_TAGS=${PUSH_TAGS},docker.io/aflplusplus/aflplusplus:latest + fi + export PUSH_TAGS + echo "::set-output name=PUSH_TAGS::${PUSH_TAGS}" + - name: Push to docker.io registry + uses: docker/build-push-action@v3 + with: + context: . + platforms: linux/amd64,linux/arm64 + push: true + tags: ${{ steps.push-tags.outputs.PUSH_TAGS }} + cache-from: type=gha diff --git a/Dockerfile b/Dockerfile index a9be22de..29ca2a5f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -63,11 +63,11 @@ RUN git clone --depth=1 https://github.com/vanhauser-thc/afl-cov && \ (cd afl-cov && make install) && rm -rf afl-cov # Until gcc v12.1 is released for ubuntu https://bugs.launchpad.net/ubuntu/+source/gcc-11/+bug/1940029 -ARG NO_NYX=1 +ENV NO_NYX=1 # Build currently broken -ARG NO_CORESIGHT=1 -ARG NO_UNICORN_ARM64=1 +ENV NO_CORESIGHT=1 +ENV NO_UNICORN_ARM64=1 WORKDIR /AFLplusplus COPY . . @@ -75,8 +75,12 @@ COPY . . ARG CC=gcc-$GCC_VERSION ARG CXX=g++-$GCC_VERSION +# Used in CI to prevent a 'make clean' which would remove the binaries to be tested +ARG TEST_BUILD + RUN sed -i.bak 's/^ -/ /g' GNUmakefile && \ - make clean && make distrib && make install && make clean && \ + make clean && make distrib && \ + ([ "${TEST_BUILD}" ] || (make install && make clean)) && \ mv GNUmakefile.bak GNUmakefile RUN echo "set encoding=utf-8" > /root/.vimrc && \ -- cgit 1.4.1