summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErlang/OTP <otp@erlang.org>2021-02-19 11:39:22 +0100
committerErlang/OTP <otp@erlang.org>2021-02-19 11:39:22 +0100
commitb375e2ed5751160db1b3fa5f0494f62e6a0b12a7 (patch)
tree611fd9c8e83c818b27039e6e7307ff28d1dd749c
parent70a94146d27e57524b34d79ab915adf54347ba0a (diff)
parent423ad4788841899c03206896b257044567ac7cf0 (diff)
downloaderlang-b375e2ed5751160db1b3fa5f0494f62e6a0b12a7.tar.gz
Merge branch 'lukas/add-github-actions' into maint-22
* lukas/add-github-actions: Fix github action base image build Try to fix buildx caches Rework docker build to use new docker build action
-rw-r--r--.github/dockerfiles/Dockerfile.cross-compile10
-rw-r--r--.github/dockerfiles/Dockerfile.debian-base53
-rwxr-xr-x.github/scripts/base-tag20
-rw-r--r--.github/workflows/main.yaml35
-rw-r--r--.github/workflows/update-base.yaml57
5 files changed, 105 insertions, 70 deletions
diff --git a/.github/dockerfiles/Dockerfile.cross-compile b/.github/dockerfiles/Dockerfile.cross-compile
index 868f8beed1..98f7f0e576 100644
--- a/.github/dockerfiles/Dockerfile.cross-compile
+++ b/.github/dockerfiles/Dockerfile.cross-compile
@@ -3,9 +3,6 @@
##
FROM docker.pkg.github.com/erlang/otp/i386-debian-base as build
-ARG HOST_ARCH=amd64
-ARG HOST_TRIP=x86_64-linux-gnu
-
ARG MAKEFLAGS=-j4
ENV MAKEFLAGS=$MAKEFLAGS \
ERLC_USE_SERVER=yes \
@@ -21,7 +18,8 @@ WORKDIR /buildroot/otp/
RUN ./configure && make && make install
## Build pre-build tar ball
-RUN scripts/build-otp-tar -o /buildroot/otp_clean_src.tar.gz /buildroot/otp_src.tar.gz -b /buildroot/otp/ /buildroot/otp.tar.gz
+RUN scripts/build-otp-tar -o /buildroot/otp_clean_src.tar.gz /buildroot/otp_src.tar.gz \
+ -b /buildroot/otp/ /buildroot/otp.tar.gz
## Prepare for a new build using pre-built tar ball
RUN cd .. && rm -rf otp && tar -xzf ./otp_src.tar.gz
@@ -43,7 +41,9 @@ RUN ./configure --prefix=/otp/ --host=$HOST --build=`erts/autoconf/config.guess`
## Build the cross tests
RUN ./otp_build tests
RUN cd release/tests/test_server && \
- erl -sname test@docker -noshell -eval "ts:install([{cross,\"yes\"},{crossflags,[{\"host\",\"$HOST\"}]},{crossroot,\"/$ERL_TOP\"}])." -s ts compile_testcases -s init stop
+ erl -sname test@docker -noshell \
+ -eval "ts:install([{cross,\"yes\"},{crossflags,[{\"host\",\"$HOST\"}]},{crossroot,\"/$ERL_TOP\"}])." \
+ -s ts compile_testcases -s init stop
FROM debian as install
diff --git a/.github/dockerfiles/Dockerfile.debian-base b/.github/dockerfiles/Dockerfile.debian-base
index 1c26677959..416edd97c9 100644
--- a/.github/dockerfiles/Dockerfile.debian-base
+++ b/.github/dockerfiles/Dockerfile.debian-base
@@ -6,29 +6,38 @@ FROM $BASE
## Need to have a second arg here as the first does not expose the $BASE in the script below
ARG BASE=debian
-ARG HOST_ARCH=amd64
ARG HOST_TRIP=x86_64-linux-gnu
+ENV HOST_TRIP=$HOST_TRIP
-ENV INSTALL_LIBS="zlib1g-dev libncurses5-dev libssh-dev unixodbc-dev libgmp3-dev libwxbase3.0-dev libwxgtk3.0-dev libsctp-dev lksctp-tools"
+ENV INSTALL_LIBS="zlib1g-dev libncurses5-dev libssh-dev unixodbc-dev libgmp3-dev libwxbase3.0-dev libwxgtk3.0-dev libwxgtk-webview3.0-gtk3-dev libsctp-dev lksctp-tools"
## See https://wiki.debian.org/Multiarch/HOWTO for details on how to install things
-RUN if [ "$BASE" = "i386/debian" ]; then BUILD_ARCH=`dpkg --print-architecture` && \
- dpkg --add-architecture $HOST_ARCH && \
- sed -i "s:deb http:deb [arch=$BUILD_ARCH,$HOST_ARCH] http:g" /etc/apt/sources.list; \
- fi
-
-RUN apt-get update && \
- apt-get -y upgrade && \
- apt-get install -y build-essential m4 autoconf fop xsltproc \
- default-jdk libxml2-utils $INSTALL_LIBS
-
-RUN if [ "$BASE" = "i386/debian" ]; then apt-get install -y \
- crossbuild-essential-$HOST_ARCH \
- $(for LIB in $INSTALL_LIBS; do echo "$LIB:$HOST_ARCH"; done) && \
- for dir in `find / -type d -name $HOST_TRIP`; do \
- echo -n "$dir: /buildroot/sysroot"; \
- echo `dirname $dir`; \
- mkdir -p /buildroot/sysroot$dir; \
- cp -r `dirname $dir`/* `dirname /buildroot/sysroot$dir`; \
- cp -r $dir/* `dirname /buildroot/sysroot$dir`; \
- done; fi
+##
+## 1. Install build-essential to get access to dpkg-architecture
+## 2. Use dpkg-architecture to figure out what we are runnon on
+## 3. If the HOST_TRIP does not equal BUILD_TRIP we should cross compile
+RUN apt-get update && apt-get -y upgrade && apt-get install -y build-essential && \
+ BUILD_TRIP=`dpkg-architecture -t${HOST_TRIP} -qDEB_BUILD_MULTIARCH` && \
+ BUILD_ARCH=`dpkg-architecture -t${HOST_TRIP} -qDEB_BUILD_ARCH` && \
+ if [ "$HOST_TRIP" != "$BUILD_TRIP" ]; then \
+ HOST_ARCH=`dpkg-architecture -t${HOST_TRIP} -qDEB_HOST_ARCH` && \
+ dpkg --add-architecture $HOST_ARCH && \
+ sed -i "s:deb http:deb [arch=$BUILD_ARCH,$HOST_ARCH] http:g" /etc/apt/sources.list; \
+ fi && \
+ apt-get update && \
+ apt-get install -y build-essential m4 autoconf fop xsltproc default-jdk libxml2-utils \
+ $INSTALL_LIBS && \
+ if [ "$HOST_TRIP" != "$BUILD_TRIP" ]; then \
+ apt-get install -y \
+ crossbuild-essential-$HOST_ARCH \
+ $(for LIB in $INSTALL_LIBS; do echo "$LIB:$HOST_ARCH"; done) && \
+ for dir in `find / -type d -name $HOST_TRIP`; do \
+ echo -n "$dir: /buildroot/sysroot"; \
+ echo `dirname $dir`; \
+ mkdir -p /buildroot/sysroot$dir; \
+ cp -r `dirname $dir`/* `dirname /buildroot/sysroot$dir`; \
+ cp -r $dir/* `dirname /buildroot/sysroot$dir`; \
+ done; \
+ fi && \
+ update-alternatives --set wx-config /usr/lib/${BUILD_TRIP}/wx/config/gtk3-unicode-3.0 && \
+ rm -rf /var/lib/apt/lists/*
diff --git a/.github/scripts/base-tag b/.github/scripts/base-tag
new file mode 100755
index 0000000000..6683793762
--- /dev/null
+++ b/.github/scripts/base-tag
@@ -0,0 +1,20 @@
+#!/bin/bash
+
+set -x
+
+case "$1" in
+ *i386-debian-base)
+ BASE="i386/debian"
+ BASE_TYPE=debian-base
+ ;;
+ *debian-base)
+ BASE="debian"
+ BASE_TYPE=debian-base
+ ;;
+ *ubuntu-base)
+ BASE="ubuntu"
+ BASE_TYPE=ubuntu-base
+ ;;
+esac
+echo "::set-output name=BASE::${BASE}"
+echo "::set-output name=BASE_TYPE::${BASE_TYPE}"
diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml
index bded7e7549..988bf3b07e 100644
--- a/.github/workflows/main.yaml
+++ b/.github/workflows/main.yaml
@@ -10,6 +10,12 @@
## Also once the windows runner supports WSL we should implement
## support for building Erlang/OTP here.
##
+## When ghcr.io support using the GITHUB_TOKEN we should migrate
+## over to use it instead as that should allow us to use the
+## built-in caching mechanisms of docker/build-push-action@v2.
+## However as things are now we use docker directly to make things
+## work.
+##
name: Build and check Erlang/OTP
@@ -62,20 +68,35 @@ jobs:
uses: actions/download-artifact@v2
with:
name: otp_git_archive
- ## We need to login to the package registry in order to pull
- ## the base debian image.
- name: Docker login
- run: docker login https://docker.pkg.github.com -u ${{ github.actor }} -p ${{ secrets.GITHUB_TOKEN }}
+ uses: docker/login-action@v1
+ with:
+ registry: docker.pkg.github.com
+ username: ${{ github.repository_owner }}
+ password: ${{ secrets.GITHUB_TOKEN }}
+ - name: Calculate BASE image
+ id: base
+ run: |
+ BASE_TAG=$(grep "^FROM" .github/dockerfiles/Dockerfile.${{ matrix.type }} | head -1 | awk '{print $2}')
+ echo "::set-output name=BASE_TAG::${BASE_TAG}"
+ .github/scripts/base-tag "${BASE_TAG}"
+ - name: Pull BASE image
+ run: docker pull ${{ steps.base.outputs.BASE_TAG }}
+ - name: Build BASE image
+ run: |
+ docker build --pull --tag ${{ steps.base.outputs.BASE_TAG }} \
+ --cache-from ${{ steps.base.outputs.BASE_TAG }} \
+ --file .github/dockerfiles/Dockerfile.${{ steps.base.outputs.BASE_TYPE }} \
+ --build-arg BASE=${{ steps.base.outputs.BASE }} .
- name: Build ${{ matrix.type }} image
run: |
- docker build -t otp --build-arg ARCHIVE=otp_src.tar.gz \
- -f .github/dockerfiles/Dockerfile.${{ matrix.type }} .
+ docker build --tag otp --file .github/dockerfiles/Dockerfile.${{ matrix.type }} \
+ --build-arg ARCHIVE=otp_src.tar.gz .
## Smoke build tests
- if: matrix.type == '32-bit' || matrix.type == '64-bit' || matrix.type == 'cross-compile'
name: Run smoke test
- run: |
- docker run -v $PWD/scripts:/scripts otp "cd /tests && /scripts/run-smoke-tests"
+ run: docker run -v $PWD/scripts:/scripts otp "cd /tests && /scripts/run-smoke-tests"
## Documentation checks
- if: matrix.type == 'documentation'
diff --git a/.github/workflows/update-base.yaml b/.github/workflows/update-base.yaml
index ed250262e7..6cf2eafac2 100644
--- a/.github/workflows/update-base.yaml
+++ b/.github/workflows/update-base.yaml
@@ -9,48 +9,33 @@ on:
## Build base images to be used by other github workflows
jobs:
- build-debian-64bit:
+ build:
+ name: Update base Erlang/OTP build images
if: github.repository == 'erlang/otp'
runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@v2
- - name: Build and push 64-bit base image
- uses: docker/build-push-action@v1
- with:
- username: ${{ github.actor }}
- password: ${{ secrets.GITHUB_TOKEN }}
- registry: docker.pkg.github.com
- dockerfile: .github/dockerfiles/Dockerfile.debian-base
- repository: erlang/otp/debian-base
- tags: latest
- build-debian-32bit:
- if: github.repository == 'erlang/otp'
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@v2
- - name: Build and push 32-bit base image
- uses: docker/build-push-action@v1
- with:
- username: ${{ github.actor }}
- password: ${{ secrets.GITHUB_TOKEN }}
- registry: docker.pkg.github.com
- dockerfile: .github/dockerfiles/Dockerfile.debian-base
- build_args: "BASE=i386/debian"
- repository: erlang/otp/i386-debian-base
- tags: latest
+ strategy:
+ matrix:
+ type: [debian-base,ubuntu-base,i386-debian-base]
- build-ubuntu-64bit:
- if: github.repository == 'erlang/otp'
- runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- - name: Build and push 64-bit base image
- uses: docker/build-push-action@v1
+ - name: Docker login
+ uses: docker/login-action@v1
with:
+ registry: docker.pkg.github.com
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- registry: docker.pkg.github.com
- dockerfile: .github/dockerfiles/Dockerfile.ubuntu-base
- repository: erlang/otp/ubuntu-base
- tags: latest
+ - name: Calculate BASE image
+ id: base
+ run: |
+ echo "::set-output name=BASE_TAG::docker.pkg.github.com/erlang/otp/${{ matrix.type }}"
+ .github/scripts/base-tag "${{ matrix.type }}"
+ - name: Build base image
+ run: |
+ docker build --pull --tag ${{ steps.base.outputs.BASE_TAG }} \
+ --cache-from ${{ steps.base.outputs.BASE_TAG }} \
+ --file .github/dockerfiles/Dockerfile.${{ steps.base.outputs.BASE_TYPE }} \
+ --build-arg BASE=${{ steps.base.outputs.BASE }} .
+ - name: Push base image
+ run: docker push ${{ steps.base.outputs.BASE_TAG }}