Fix for x86_64 build fail
[platform/upstream/connectedhomeip.git] / third_party / ot-br-posix / repo / .github / workflows / docker.yml
1 #
2 #  Copyright (c) 2020, The OpenThread Authors.
3 #  All rights reserved.
4 #
5 #  Redistribution and use in source and binary forms, with or without
6 #  modification, are permitted provided that the following conditions are met:
7 #  1. Redistributions of source code must retain the above copyright
8 #     notice, this list of conditions and the following disclaimer.
9 #  2. Redistributions in binary form must reproduce the above copyright
10 #     notice, this list of conditions and the following disclaimer in the
11 #     documentation and/or other materials provided with the distribution.
12 #  3. Neither the name of the copyright holder nor the
13 #     names of its contributors may be used to endorse or promote products
14 #     derived from this software without specific prior written permission.
15 #
16 #  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17 #  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 #  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 #  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
20 #  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 #  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 #  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 #  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 #  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 #  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 #  POSSIBILITY OF SUCH DAMAGE.
27 #
28
29 name: Docker
30
31 on: [push, pull_request]
32
33 jobs:
34
35   cancel-previous-runs:
36     runs-on: ubuntu-20.04
37     steps:
38     - uses: rokroskar/workflow-run-cleanup-action@master
39       env:
40         GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
41       if: "github.ref != 'refs/heads/master'"
42
43   docker-check:
44     runs-on: ubuntu-latest
45     strategy:
46       matrix:
47         rcp_bus: ["UART", "SPI"]
48     env:
49       OT_POSIX_CONFIG_RCP_BUS: ${{matrix.rcp_bus}}
50       OTBR_COVERAGE: 1
51       VERBOSE: 1
52     steps:
53     - uses: actions/checkout@v2
54       with:
55         submodules: true
56     - name: Bootstrap
57       env:
58         BUILD_TARGET: "docker-check"
59       run: tests/scripts/bootstrap.sh
60     - name: Check
61       run: tests/scripts/check-docker
62
63   buildx:
64     runs-on: ubuntu-20.04
65     strategy:
66       matrix:
67         include:
68           - image_tag: "latest"
69             base_image: "ubuntu:bionic"
70             build_args: ""
71             platforms: "linux/amd64,linux/arm/v7,linux/arm64"
72             push: yes
73           - image_tag: "focal"
74             base_image: "ubuntu:focal"
75             build_args: ""
76             platforms: "linux/amd64,linux/arm64"
77             push: yes
78           - image_tag: "reference-device"
79             base_image: "ubuntu:bionic"
80             build_args: "--build-arg REFERENCE_DEVICE=1 --build-arg BACKBONE_ROUTER=1 --build-arg OTBR_OPTIONS='-DOT_DUA=ON -DOT_MLR=ON' --build-arg NAT64=0"
81             platforms: "linux/amd64,linux/arm/v7,linux/arm64"
82             push: yes
83           - image_tag: "test"
84             base_image: "ubuntu:bionic"
85             build_args: "--build-arg REFERENCE_DEVICE=1 --build-arg BACKBONE_ROUTER=1 --build-arg OTBR_OPTIONS='-DOT_DUA=ON -DOT_MLR=ON' --build-arg OT_BACKBONE_CI=1"
86             platforms: "linux/amd64,linux/arm/v7,linux/arm64"
87             push: no
88     steps:
89     - uses: actions/checkout@v2
90       with:
91         submodules: true
92     - name: Set up QEMU
93       uses: docker/setup-qemu-action@v1
94       with:
95         platforms: all
96     - name: Set up Docker Buildx
97       id: buildx
98       uses: docker/setup-buildx-action@v1
99     - name: Prepare
100       id: prepare
101       run: |
102         DOCKER_IMAGE=openthread/otbr
103         DOCKER_PLATFORMS=${{ matrix.platforms }}
104         VERSION=${{ matrix.image_tag }}
105
106         TAGS="--tag ${DOCKER_IMAGE}:${VERSION}"
107
108         echo ::set-output name=docker_image::${DOCKER_IMAGE}
109         echo ::set-output name=version::${VERSION}
110         echo ::set-output name=buildx_args::"--platform ${DOCKER_PLATFORMS} \
111           --build-arg BASE_IMAGE=${{ matrix.base_image }} \
112           --build-arg VERSION=${VERSION} \
113           --build-arg BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') \
114           --build-arg VCS_REF=${GITHUB_SHA::8} \
115           ${{ matrix.build_args }} \
116           ${TAGS} --file etc/docker/Dockerfile ."
117
118     - name: Docker Buildx (build)
119       run: |
120         docker buildx build --output "type=image,push=false" ${{ steps.prepare.outputs.buildx_args }}
121
122     - name: Docker Login
123       if: success() && github.repository == 'openthread/ot-br-posix' && github.event_name != 'pull_request' && matrix.push
124       env:
125         DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
126         DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
127       run: |
128         echo "${DOCKER_PASSWORD}" | docker login --username "${DOCKER_USERNAME}" --password-stdin
129
130     - name: Docker Buildx (push)
131       if: success() && github.repository == 'openthread/ot-br-posix' && github.event_name != 'pull_request' && matrix.push
132       run: |
133         docker buildx build --output "type=image,push=true" ${{ steps.prepare.outputs.buildx_args }}
134
135     - name: Docker Check Manifest
136       if: always() && github.repository == 'openthread/ot-br-posix' && github.event_name != 'pull_request' && matrix.push
137       run: |
138         docker run --rm mplatform/mquery ${{ steps.prepare.outputs.docker_image }}:${{ steps.prepare.outputs.version }}
139
140     - name: Clear
141       if: always() && github.repository == 'openthread/ot-br-posix' && github.event_name != 'pull_request' && matrix.push
142       run: |
143         rm -f ${HOME}/.docker/config.json