diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..16f879a --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,57 @@ +name: CI + +on: + pull_request: + branches: + - master + push: + branches: + - master + - issue/* + +jobs: + build: + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v2 + # Pre-installed packages break the environment required to build BCC. + # That's why I decided to use Docker inside GitHub Actions. + - run: docker image build -f=build/Dockerfile -t box:latest . + - run: docker container run --rm --mount type=bind,source="$(pwd)",target=/workspace box:latest go build -o work/nudge . + - uses: actions/upload-artifact@v2 + with: + name: artifact + path: work/nudge + + release: + needs: build + if: github.ref == 'refs/heads/master' + runs-on: ubuntu-20.04 + steps: + - uses: actions/download-artifact@v2 + with: + name: artifact + - name: Generate build number + uses: einaregilsson/build-number@v2 + with: + token: ${{secrets.GITHUB_TOKEN}} + prefix: build_number_generator + - name: Print new build number + run: echo "Build number is $BUILD_NUMBER" + - id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} + with: + tag_name: build-${{env.BUILD_NUMBER}} + release_name: Build ${{env.BUILD_NUMBER}} + draft: false + prerelease: false + - uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} + with: + upload_url: ${{steps.create_release.outputs.upload_url}} + asset_path: ./nudge + asset_name: nudge.build-${{env.BUILD_NUMBER}}-linux-amd64 + asset_content_type: application/octet-stream diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 76b5fe4..0000000 --- a/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/work/ diff --git a/build/Dockerfile b/build/Dockerfile new file mode 100644 index 0000000..97c201d --- /dev/null +++ b/build/Dockerfile @@ -0,0 +1,53 @@ +FROM ubuntu:20.04 + +ARG BCC_VERSION=0.16.0 +ARG GO_VERSION=1.15.2 + +ENV DEBIAN_FRONTEND=noninteractive + +RUN apt-get update && apt-get install -y \ + arping \ + bison \ + build-essential \ + cmake \ + flex \ + git \ + iperf3 \ + libclang-9-dev \ + libedit-dev \ + libelf-dev \ + libllvm9 \ + llvm-9-dev \ + netperf \ + python3 \ + python3-distutils \ + zlib1g-dev + +RUN cd /var/tmp && git clone -b v${BCC_VERSION} https://github.com/iovisor/bcc.git +RUN mkdir -p /var/tmp/bcc/build && cd /var/tmp/bcc/build + +RUN update-alternatives --install /usr/local/bin/python python /usr/bin/python3.8 1 + +WORKDIR /var/tmp/bcc/build + +RUN cmake .. +RUN make +RUN make install + +# build python3 binding +RUN cmake -DPYTHON_CMD=python3 .. + +WORKDIR /var/tmp/bcc/build/src/python + +RUN make +RUN make install + +RUN mkdir -p /var/tmp/go +WORKDIR /var/tmp/go +RUN apt-get install -y curl + +RUN curl -sSfL https://golang.org/dl/go${GO_VERSION}.linux-amd64.tar.gz | tar -C /usr/local -xz +ENV PATH $PATH:/usr/local/go/bin + +RUN mkdir /workspace +WORKDIR /workspace diff --git a/script b/script new file mode 100644 index 0000000..e69de29 diff --git a/work/.gitignore b/work/.gitignore new file mode 100644 index 0000000..d6b7ef3 --- /dev/null +++ b/work/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore