From 257d973acb07847639463fb59ad75b48dde51875 Mon Sep 17 00:00:00 2001 From: Lucas Teske Date: Fri, 15 Jan 2021 20:10:07 -0300 Subject: [PATCH 1/4] add 'apicula' workflow, dockerfile and test (#11) --- .github/workflows/apicula.yml | 65 +++++++++++++++++++++++++++++++++++ apicula.dockerfile | 44 ++++++++++++++++++++++++ debian-buster/base.dockerfile | 1 + doc/tools.yml | 9 +++++ test/apicula.pkg.sh | 29 ++++++++++++++++ test/apicula.sh | 31 +++++++++++++++++ 6 files changed, 179 insertions(+) create mode 100644 .github/workflows/apicula.yml create mode 100644 apicula.dockerfile create mode 100755 test/apicula.pkg.sh create mode 100755 test/apicula.sh diff --git a/.github/workflows/apicula.yml b/.github/workflows/apicula.yml new file mode 100644 index 00000000..bf05d156 --- /dev/null +++ b/.github/workflows/apicula.yml @@ -0,0 +1,65 @@ +# Authors: +# Unai Martinez-Corral +# Lucas Teske +# +# Copyright 2019-2021 Unai Martinez-Corral +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 + +name: 'apicula' + +on: + pull_request: + push: + schedule: + - cron: '0 0 * * 5' + workflow_dispatch: + repository_dispatch: + types: [ apicula ] + +env: + DOCKER_BUILDKIT: 1 + +jobs: + + apicula: + runs-on: ubuntu-latest + steps: + + - uses: actions/checkout@v2 + with: + submodules: recursive + + - run: echo "$(pwd)/.github/bin" >> $GITHUB_PATH + + - run: dockerBuild pkg:apicula apicula pkg + - run: dockerBuild apicula apicula + + - run: dockerTestPkg apicula + - run: dockerTest apicula + + - name: Login to DockerHub + if: github.event_name != 'pull_request' && github.repository == 'hdl/containers' + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKER_USER }} + password: ${{ secrets.DOCKER_PASS }} + + - run: dockerPush pkg:apicula + if: github.event_name != 'pull_request' && github.repository == 'hdl/containers' + + - run: dockerPush apicula + if: github.event_name != 'pull_request' && github.repository == 'hdl/containers' + diff --git a/apicula.dockerfile b/apicula.dockerfile new file mode 100644 index 00000000..6831ec06 --- /dev/null +++ b/apicula.dockerfile @@ -0,0 +1,44 @@ +# syntax=docker/dockerfile:experimental +# Authors: +# Unai Martinez-Corral +# Lucas Teske +# +# Copyright 2019-2021 Unai Martinez-Corral +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 + +FROM hdlc/build:build AS build + +RUN apt-get update -qq \ + && DEBIAN_FRONTEND=noninteractive apt-get -y install --no-install-recommends wget + +RUN mkdir /opt/apicula \ + && wget https://files.pythonhosted.org/packages/1a/d6/b3162f87ff114d639095fe7c0655080ee16caff9037d6629f738d8b28d92/Apycula-0.0.1a6.tar.gz \ + && tar -xvf Apycula-0.0.1a6.tar.gz --strip-components=1 -C /opt/apicula \ + && ls -lah /opt/apicula + +#--- + +FROM scratch AS pkg +COPY --from=build /opt/apicula /apicula + +#--- + +FROM hdlc/build:base + +RUN --mount=type=cache,from=build,src=/opt/apicula,target=/opt/apicula cd /opt/apicula \ + && python3 setup.py install \ + && rm -rf ~/.cache + diff --git a/debian-buster/base.dockerfile b/debian-buster/base.dockerfile index 044a8486..94bd8e11 100644 --- a/debian-buster/base.dockerfile +++ b/debian-buster/base.dockerfile @@ -24,6 +24,7 @@ RUN apt-get update -qq \ ca-certificates \ curl \ python3 \ + python3-setuptools \ && apt-get autoclean && apt-get clean && apt-get -y autoremove \ && update-ca-certificates \ && rm -rf /var/lib/apt/lists/* diff --git a/doc/tools.yml b/doc/tools.yml index 1f310648..826fbf1a 100644 --- a/doc/tools.yml +++ b/doc/tools.yml @@ -254,3 +254,12 @@ z3: - 'formal:min' - 'formal' - 'formal:all' + +#--- + +apicula: + url: 'https://hdl.github.io/awesome/items/apicula' + pkg: + - 'apicula' + use: + - 'apicula' diff --git a/test/apicula.pkg.sh b/test/apicula.pkg.sh new file mode 100755 index 00000000..c745a0c9 --- /dev/null +++ b/test/apicula.pkg.sh @@ -0,0 +1,29 @@ +#!/bin/sh + +# Authors: +# Unai Martinez-Corral +# Lucas Teske +# +# Copyright 2020-2021 Unai Martinez-Corral +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 + +set -e + +cd $(dirname "$0") + +tree / + +./_todo.sh diff --git a/test/apicula.sh b/test/apicula.sh new file mode 100755 index 00000000..3d7af181 --- /dev/null +++ b/test/apicula.sh @@ -0,0 +1,31 @@ +#!/usr/bin/env sh + +# Authors: +# Unai Martinez-Corral +# Lucas Teske +# +# Copyright 2020-2021 Unai Martinez-Corral +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 + +set -e + +cd $(dirname "$0") + +./_env.sh + +./smoke-tests/apicula.sh + +./_todo.sh From 9a0369436546c9c78539e1f91954df51d68aa340 Mon Sep 17 00:00:00 2001 From: umarcor Date: Thu, 8 Apr 2021 03:35:02 +0200 Subject: [PATCH 2/4] apicula: rebase and update (#11) --- .github/workflows/apicula.yml | 43 +++++++++++++++++++----- apicula.dockerfile | 44 ------------------------ debian-buster/apicula.dockerfile | 57 ++++++++++++++++++++++++++++++++ debian-buster/base.dockerfile | 1 - test/apicula.pkg.sh | 4 ++- 5 files changed, 95 insertions(+), 54 deletions(-) delete mode 100644 apicula.dockerfile create mode 100644 debian-buster/apicula.dockerfile diff --git a/.github/workflows/apicula.yml b/.github/workflows/apicula.yml index bf05d156..ca0f2552 100644 --- a/.github/workflows/apicula.yml +++ b/.github/workflows/apicula.yml @@ -36,6 +36,11 @@ jobs: apicula: runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + os: + - debian-buster steps: - uses: actions/checkout@v2 @@ -44,11 +49,25 @@ jobs: - run: echo "$(pwd)/.github/bin" >> $GITHUB_PATH - - run: dockerBuild pkg:apicula apicula pkg - - run: dockerBuild apicula apicula + - run: dockerBuild -b ${{ matrix.os }} -i pkg:apicula -d apicula -t pkg + - run: dockerBuild -b ${{ matrix.os }} -i apicula -d apicula - - run: dockerTestPkg apicula - - run: dockerTest apicula + - run: dockerTestPkg ${{ matrix.os }} apicula + - run: dockerTest ${{ matrix.os }} apicula + + - name: Login to ghcr.io + if: github.event_name != 'pull_request' && github.repository == 'hdl/containers' + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: gha + password: ${{ github.token }} + + - if: github.event_name != 'pull_request' && github.repository == 'hdl/containers' + run: >- + dockerPush ${{ matrix.os }} + pkg:apicula + apicula - name: Login to DockerHub if: github.event_name != 'pull_request' && github.repository == 'hdl/containers' @@ -57,9 +76,17 @@ jobs: username: ${{ secrets.DOCKER_USER }} password: ${{ secrets.DOCKER_PASS }} - - run: dockerPush pkg:apicula - if: github.event_name != 'pull_request' && github.repository == 'hdl/containers' + # Mirror to docker.io/hdlc - - run: dockerPush apicula - if: github.event_name != 'pull_request' && github.repository == 'hdl/containers' + - name: Login to docker.io + if: github.event_name != 'pull_request' && github.repository == 'hdl/containers' && ${{ matrix.os }} == 'debian-buster' + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKER_USER }} + password: ${{ secrets.DOCKER_PASS }} + - if: github.event_name != 'pull_request' && github.repository == 'hdl/containers' && ${{ matrix.os }} == 'debian-buster' + run: >- + dockerMirror ${{ matrix.os }} + pkg:apicula + apicula diff --git a/apicula.dockerfile b/apicula.dockerfile deleted file mode 100644 index 6831ec06..00000000 --- a/apicula.dockerfile +++ /dev/null @@ -1,44 +0,0 @@ -# syntax=docker/dockerfile:experimental -# Authors: -# Unai Martinez-Corral -# Lucas Teske -# -# Copyright 2019-2021 Unai Martinez-Corral -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# SPDX-License-Identifier: Apache-2.0 - -FROM hdlc/build:build AS build - -RUN apt-get update -qq \ - && DEBIAN_FRONTEND=noninteractive apt-get -y install --no-install-recommends wget - -RUN mkdir /opt/apicula \ - && wget https://files.pythonhosted.org/packages/1a/d6/b3162f87ff114d639095fe7c0655080ee16caff9037d6629f738d8b28d92/Apycula-0.0.1a6.tar.gz \ - && tar -xvf Apycula-0.0.1a6.tar.gz --strip-components=1 -C /opt/apicula \ - && ls -lah /opt/apicula - -#--- - -FROM scratch AS pkg -COPY --from=build /opt/apicula /apicula - -#--- - -FROM hdlc/build:base - -RUN --mount=type=cache,from=build,src=/opt/apicula,target=/opt/apicula cd /opt/apicula \ - && python3 setup.py install \ - && rm -rf ~/.cache - diff --git a/debian-buster/apicula.dockerfile b/debian-buster/apicula.dockerfile new file mode 100644 index 00000000..9f07e6ba --- /dev/null +++ b/debian-buster/apicula.dockerfile @@ -0,0 +1,57 @@ +# syntax=docker/dockerfile:1.2 + +# Authors: +# Unai Martinez-Corral +# Lucas Teske +# +# Copyright 2019-2021 Unai Martinez-Corral +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 + +ARG REGISTRY='ghcr.io/hdl/debian-buster' + +#--- + +FROM $REGISTRY/build:build AS build + +RUN apt-get update -qq \ + && DEBIAN_FRONTEND=noninteractive apt-get -y install --no-install-recommends \ + python3-dev \ + python3-setuptools \ + python3-wheel + +RUN mkdir /opt/apicula /tmp/apicula \ + && curl -fsSL https://files.pythonhosted.org/packages/1a/d6/b3162f87ff114d639095fe7c0655080ee16caff9037d6629f738d8b28d92/Apycula-0.0.1a6.tar.gz | tar -xvzf - --strip-components=1 -C /opt/apicula \ + && cd /opt/apicula \ + && python3 setup.py bdist_wheel \ + && mv dist/*.whl /tmp/apicula/ + +#--- + +FROM scratch AS pkg +COPY --from=build /tmp/apicula /apicula + +#--- + +FROM $REGISTRY/build:base + +RUN apt-get update -qq \ + && DEBIAN_FRONTEND=noninteractive apt-get -y install --no-install-recommends \ + python3-pip \ + python3-setuptools \ + python3-wheel + +RUN --mount=type=cache,from=build,src=/tmp/apicula,target=/tmp/apicula pip3 install -U /tmp/apicula/*.whl --progress-bar off \ + && rm -rf ~/.cache diff --git a/debian-buster/base.dockerfile b/debian-buster/base.dockerfile index 94bd8e11..044a8486 100644 --- a/debian-buster/base.dockerfile +++ b/debian-buster/base.dockerfile @@ -24,7 +24,6 @@ RUN apt-get update -qq \ ca-certificates \ curl \ python3 \ - python3-setuptools \ && apt-get autoclean && apt-get clean && apt-get -y autoremove \ && update-ca-certificates \ && rm -rf /var/lib/apt/lists/* diff --git a/test/apicula.pkg.sh b/test/apicula.pkg.sh index c745a0c9..b97ad170 100755 --- a/test/apicula.pkg.sh +++ b/test/apicula.pkg.sh @@ -24,6 +24,8 @@ set -e cd $(dirname "$0") -tree / +./_tree.sh + +ls -la /*.whl ./_todo.sh From 7047984369867b1d2dbe63d3c1c5a52f1333498e Mon Sep 17 00:00:00 2001 From: umarcor Date: Thu, 8 Apr 2021 04:19:35 +0200 Subject: [PATCH 3/4] doc: add apicula to ci and graphs --- doc/development.adoc | 5 +++++ graph/graph.dot | 4 ++++ graph/impl.dot | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+) diff --git a/doc/development.adoc b/doc/development.adoc index 9b777c99..15ba47e8 100644 --- a/doc/development.adoc +++ b/doc/development.adoc @@ -37,6 +37,11 @@ GHAStatus:verilator[] a|* {blank} + -- +GHAStatus:apicula[] +-- +* {blank} ++ +-- GHAStatus:ghdl-yosys-plugin[] -- * {blank} diff --git a/graph/graph.dot b/graph/graph.dot index a806df82..8d6c0238 100644 --- a/graph/graph.dot +++ b/graph/graph.dot @@ -40,6 +40,7 @@ digraph G { "build:build" "build:dev" { node [color=limegreen, fontcolor=limegreen] + "apicula" "arachne-pnr" "ghdl" "ghdl:llvm" @@ -57,6 +58,7 @@ digraph G { "yosys" } { node [color=mediumblue, fontcolor=mediumblue] + "pkg:apicula" "pkg:arachne-pnr" "pkg:boolector" "pkg:cvc4" @@ -186,6 +188,8 @@ digraph G { subgraph cluster_impl { label = "Impl"; m_impl -> { + "apicula" + "pkg:apicula" "arachne-pnr" "pkg:arachne-pnr" "icestorm" diff --git a/graph/impl.dot b/graph/impl.dot index 5abf7fd7..17288ba2 100644 --- a/graph/impl.dot +++ b/graph/impl.dot @@ -25,6 +25,7 @@ digraph G { # Dockerfiles { node [shape=note, color=dodgerblue, fontcolor=dodgerblue] + d_apicula [label="apicula"]; d_arachnepnr [label="arachne-pnr"]; d_icestorm [label="icestorm"]; d_impl [label="impl"]; @@ -40,6 +41,7 @@ digraph G { "build:build" "build:dev" { node [color=limegreen, fontcolor=limegreen] + "apicula" "arachne-pnr" "ghdl:yosys" "icestorm" @@ -52,6 +54,7 @@ digraph G { "nextpnr" } { node [color=mediumblue, fontcolor=mediumblue] + "pkg:apicula" "pkg:arachne-pnr" "pkg:icestorm" "pkg:prjtrellis" @@ -87,6 +90,29 @@ digraph G { # Workflows + subgraph cluster_apicula { + { rank=same + node [shape=cylinder, color=grey, fontcolor=grey] + "p_apicula_build:build" [label="build:build"] + "p_apicula_build:base" [label="build:base"] + "p_apicula_scratch" [label="scratch"] + } + + d_apicula -> { + "apicula" + "pkg:apicula" + } [style=dotted]; + + { rank=same + node [shape=folder, color=red, fontcolor=red] + "t_apicula" [label="apicula"]; + "t_pkg:apicula" [label="apicula.pkg"]; + } + + "apicula" -> "t_apicula"; + "pkg:apicula" -> "t_pkg:apicula"; + } + subgraph cluster_arachenpnr { { rank=same node [shape=cylinder, color=grey, fontcolor=grey] @@ -291,6 +317,10 @@ digraph G { # Dockerfile dependencies + "build:build" -> "p_apicula_build:build" -> d_apicula; + "build:base" -> "p_apicula_build:base" -> d_apicula; + "scratch" -> "p_apicula_scratch" -> d_apicula; + "build:build" -> "p_arachnepnr_build:build" -> d_arachnepnr; "build:base" -> "p_arachnepnr_build:base" -> d_arachnepnr; "scratch" -> "p_arachnepnr_scratch" -> d_arachnepnr; @@ -324,6 +354,9 @@ digraph G { # Image dependencies { edge [style=dashed] + "p_apicula_build:base" -> "apicula"; + "p_apicula_scratch" -> "pkg:apicula"; + "p_arachnepnr_build:base" -> "arachne-pnr"; "p_arachnepnr_scratch" -> "pkg:arachne-pnr"; From 055086c42e7157902c6e909b5d58144923c6b7a1 Mon Sep 17 00:00:00 2001 From: umarcor Date: Thu, 8 Apr 2021 05:15:59 +0200 Subject: [PATCH 4/4] apicula: support overriding the base image --- debian-buster/apicula.dockerfile | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/debian-buster/apicula.dockerfile b/debian-buster/apicula.dockerfile index 9f07e6ba..ccc1b0e8 100644 --- a/debian-buster/apicula.dockerfile +++ b/debian-buster/apicula.dockerfile @@ -21,6 +21,7 @@ # SPDX-License-Identifier: Apache-2.0 ARG REGISTRY='ghcr.io/hdl/debian-buster' +ARG IMAGE="build:base" #--- @@ -45,7 +46,10 @@ COPY --from=build /tmp/apicula /apicula #--- -FROM $REGISTRY/build:base +# WORKAROUND: this is required because '--mount=' does not support ARGs +FROM $REGISTRY/pkg:apicula AS pkg-apicula + +FROM $REGISTRY/$IMAGE RUN apt-get update -qq \ && DEBIAN_FRONTEND=noninteractive apt-get -y install --no-install-recommends \ @@ -53,5 +57,6 @@ RUN apt-get update -qq \ python3-setuptools \ python3-wheel -RUN --mount=type=cache,from=build,src=/tmp/apicula,target=/tmp/apicula pip3 install -U /tmp/apicula/*.whl --progress-bar off \ +RUN --mount=type=cache,from=pkg-apicula,src=/apicula,target=/tmp/apicula/ \ + pip3 install -U /tmp/apicula/*.whl --progress-bar off \ && rm -rf ~/.cache