From 7af1cb3ac4d50155711f211f71f2d0fc0758b43a Mon Sep 17 00:00:00 2001 From: Jef Roosens Date: Fri, 15 Apr 2022 09:52:10 +0200 Subject: [PATCH] ci: Added docker workflow & Dockerfile --- .woodpecker.yml | 61 ++++++++++++++++++++++++++++++++++++++++++++++ Dockerfile.builder | 33 +++++++++++++++++++++++++ GNUmakefile | 2 +- Makefile | 2 +- 4 files changed, 96 insertions(+), 2 deletions(-) create mode 100644 .woodpecker.yml create mode 100644 Dockerfile.builder diff --git a/.woodpecker.yml b/.woodpecker.yml new file mode 100644 index 0000000000..a3ebf890e2 --- /dev/null +++ b/.woodpecker.yml @@ -0,0 +1,61 @@ +platform: 'linux/amd64' +branches: ['master'] + +pipeline: + gen-vc: + # This is what the official CI uses as well + image: 'ubuntu:latest' + secrets: + - deploy_key + commands: + # Install necessary dependencies + - apt-get update -y && apt-get install openssh-client git build-essential -y + # Build the compiler + - make + # Run ssh-agent + - eval $(ssh-agent -s) + # Add ssh key + - echo "$DEPLOY_KEY" | tr -d '\r' | ssh-add - + # Create ssh dir with proper permissions + - mkdir -p ~/.ssh + - chmod 700 ~/.ssh + # Configure git credentials + - git config --global user.email 'vbot@rustybever.be' + - git config --global user.name 'vbot' + # Verify SSH keys + - ssh-keyscan git.rustybever.be > ~/.ssh/known_hosts + + # The following is copied over from the official repo's CI + # https://github.com/vlang/v/blob/master/.github/workflows/gen_vc.yml + - export "COMMIT_HASH=$(git rev-parse --short HEAD)" + - export "COMMIT_MSG=$(git log -1 --oneline --pretty='%s' HEAD)" + - rm -rf vc + - git clone --depth=1 'git@git.rustybever.be:vieter/vc.git' + - rm -rf vc/v.c vc/v_win.c + - ./v -o vc/v.c -os cross cmd/v + - ./v -o vc/v_win.c -os windows -cc msvc cmd/v + - sed -i "1s/^/#define V_COMMIT_HASH \"$COMMIT_HASH\"\n/" vc/v.c + - sed -i "1s/^/#define V_COMMIT_HASH \"$COMMIT_HASH\"\n/" vc/v_win.c + # ensure the C files are over 5000 lines long, as a safety measure + - '[ $(wc -l < vc/v.c) -gt 5000 ]' + - '[ $(wc -l < vc/v_win.c) -gt 5000 ]' + - git -C vc add v.c v_win.c + - 'git -C vc commit -m "[v:master] $COMMIT_HASH - $COMMIT_MSG"' + # in case there are recent commits: + - git -C vc pull --rebase origin main + - git -C vc push + when: + event: push + + publish: + image: woodpeckerci/plugin-docker-buildx + secrets: [ docker_username, docker_password ] + settings: + repo: chewingbever/vlang + tag: latest + dockerfile: Dockerfile.builder + platforms: [ linux/arm64/v8, linux/amd64 ] + # The build can run every time, because we should only push when there's + # actual changes + when: + event: push diff --git a/Dockerfile.builder b/Dockerfile.builder new file mode 100644 index 0000000000..6f0965e52e --- /dev/null +++ b/Dockerfile.builder @@ -0,0 +1,33 @@ +FROM alpine:3.12 + +ARG TARGETPLATFORM + +WORKDIR /opt/vlang + +ENV VVV /opt/vlang +ENV PATH /opt/vlang:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin +ENV VFLAGS -cc gcc -d dynamic_boehm +ENV V_PATH /opt/vlang/v + +RUN ln -s /opt/vlang/v /usr/bin/v && \ + apk --no-cache add \ + git make gcc curl openssl \ + musl-dev \ + openssl-libs-static openssl-dev \ + zlib-static bzip2-static xz-dev expat-static zstd-static lz4-static \ + sqlite-static sqlite-dev \ + libx11-dev glfw-dev freetype-dev \ + libarchive-static libarchive-dev \ + gc-dev \ + diffutils + +RUN git clone https://git.rustybever.be/Chewing_Bever/v /opt/vlang && \ + make && \ + v -version + +RUN if [ "$TARGETPLATFORM" = 'linux/amd64' ]; then \ + wget -O /usr/local/bin/mc https://dl.min.io/client/mc/release/linux-amd64/mc && \ + chmod +x /usr/local/bin/mc ; \ +fi + +CMD ["v"] diff --git a/GNUmakefile b/GNUmakefile index 9b97c64e4c..51c0ccb9cf 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -5,7 +5,7 @@ TMPDIR ?= /tmp VROOT ?= . VC ?= ./vc V ?= ./v -VCREPO ?= https://github.com/vlang/vc +VCREPO ?= https://git.rustybever.be/vieter/vc TCCREPO ?= https://github.com/vlang/tccbin VCFILE := v.c diff --git a/Makefile b/Makefile index 67d579a99f..f70ee1c42b 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ LDFLAGS ?= all: rm -rf vc/ - git clone --depth 1 --quiet https://github.com/vlang/vc + git clone --depth 1 --quiet https://git.rustybever.be/vieter/vc $(CC) $(CFLAGS) -std=gnu11 -w -o v1 vc/v.c -lm -lexecinfo -lpthread $(LDFLAGS) ./v1 -no-parallel -o v2 $(VFLAGS) cmd/v ./v2 -o v $(VFLAGS) cmd/v