From 6130c50398c06cba9ad15531f9490c2046c747a5 Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Sat, 7 Nov 2020 14:27:06 -0800 Subject: [PATCH] infra: Adding kokoro setup. Signed-off-by: Tim 'mithro' Ansell --- .github/kokoro/continuous.cfg | 13 +++++++ .github/kokoro/presubmit.cfg | 13 +++++++ .github/kokoro/run.sh | 57 +++++++++++++++++++++++++++++++ .github/kokoro/steps/auth.sh | 35 +++++++++++++++++++ .github/kokoro/steps/git.sh | 46 +++++++++++++++++++++++++ .github/kokoro/steps/hostinfo.sh | 51 +++++++++++++++++++++++++++ .github/kokoro/steps/hostsetup.sh | 45 ++++++++++++++++++++++++ 7 files changed, 260 insertions(+) create mode 100644 .github/kokoro/continuous.cfg create mode 100644 .github/kokoro/presubmit.cfg create mode 100755 .github/kokoro/run.sh create mode 100755 .github/kokoro/steps/auth.sh create mode 100755 .github/kokoro/steps/git.sh create mode 100755 .github/kokoro/steps/hostinfo.sh create mode 100755 .github/kokoro/steps/hostsetup.sh diff --git a/.github/kokoro/continuous.cfg b/.github/kokoro/continuous.cfg new file mode 100644 index 0000000..8e80887 --- /dev/null +++ b/.github/kokoro/continuous.cfg @@ -0,0 +1,13 @@ +# Format: kokoro/config/proto/build.proto + +build_file: "skywater-pdk/.github/kokoro/run.sh" + +env_vars { + key: "KOKORO_TYPE" + value: "continuous" +} + +env_vars { + key: "KOKORO_DIR" + value: "skywater-pdk" +} diff --git a/.github/kokoro/presubmit.cfg b/.github/kokoro/presubmit.cfg new file mode 100644 index 0000000..5a36428 --- /dev/null +++ b/.github/kokoro/presubmit.cfg @@ -0,0 +1,13 @@ +# Format: kokoro/config/proto/build.proto + +build_file: "skywater-pdk/.github/kokoro/run.sh" + +env_vars { + key: "KOKORO_TYPE" + value: "presubmit" +} + +env_vars { + key: "KOKORO_DIR" + value: "skywater-pdk" +} diff --git a/.github/kokoro/run.sh b/.github/kokoro/run.sh new file mode 100755 index 0000000..f3de16a --- /dev/null +++ b/.github/kokoro/run.sh @@ -0,0 +1,57 @@ +#!/bin/bash +# -*- coding: utf-8 -*- +# +# Copyright 2020 Regents of the University of California +# +# 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 + +CALLED=$_ +[[ "${BASH_SOURCE[0]}" != "${0}" ]] && SOURCED=1 || SOURCED=0 + +SCRIPT_SRC="$(realpath ${BASH_SOURCE[0]})" +SCRIPT_DIR="$(dirname "${SCRIPT_SRC}")" + +export PATH="/usr/sbin:/usr/bin:/sbin:/bin" + +cd github/$KOKORO_DIR + +. $SCRIPT_DIR/steps/auth.sh +. $SCRIPT_DIR/steps/git.sh +. $SCRIPT_DIR/steps/hostsetup.sh +. $SCRIPT_DIR/steps/hostinfo.sh + +set -e + +echo +echo "========================================" +echo "Setting up build environment" +echo "----------------------------------------" +make env +echo "----------------------------------------" + +echo +echo "========================================" +echo "Checkout all the submodules" +echo "----------------------------------------" +DOWNLOAD_JOBS=$(($CORES*2)) +git submodule update --init --jobs $DOWNLOAD_JOBS + +echo +echo "========================================" +echo "Build the timing libraries" +echo "----------------------------------------" +make -j timing diff --git a/.github/kokoro/steps/auth.sh b/.github/kokoro/steps/auth.sh new file mode 100755 index 0000000..c7d9583 --- /dev/null +++ b/.github/kokoro/steps/auth.sh @@ -0,0 +1,35 @@ +#!/bin/bash +# -*- coding: utf-8 -*- +# +# Copyright 2020 Regents of the University of California +# +# 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 + +echo +echo "========================================" +echo "Setting up authentication" +echo "----------------------------------------" +( + cd $KOKORO_ARTIFACTS_DIR + ls -l + # Run the GOB cookie daemon to allow cloning from + # foss-eda-tools.googlesource.com + git clone https://gerrit.googlesource.com/gcompute-tools \ + $KOKORO_ARTIFACTS_DIR/gcompute-tools + $KOKORO_ARTIFACTS_DIR/gcompute-tools/git-cookie-authdaemon +) +echo "----------------------------------------" diff --git a/.github/kokoro/steps/git.sh b/.github/kokoro/steps/git.sh new file mode 100755 index 0000000..3b78cd0 --- /dev/null +++ b/.github/kokoro/steps/git.sh @@ -0,0 +1,46 @@ +#!/bin/bash +# -*- coding: utf-8 -*- +# +# Copyright 2020 Regents of the University of California +# +# 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 + +echo +echo "========================================" +echo "Git log" +echo "----------------------------------------" +git log -n5 --stat +echo "----------------------------------------" + +echo +echo "========================================" +echo "Git fetching tags" +echo "----------------------------------------" +# Don't fail if there are no tags +git fetch --tags || true +echo "----------------------------------------" + +echo +echo "========================================" +echo "Git version info" +echo "----------------------------------------" +git log -n1 +echo "----------------------------------------" +git describe --tags || true +echo "----------------------------------------" +git describe --tags --always || true +echo "----------------------------------------" diff --git a/.github/kokoro/steps/hostinfo.sh b/.github/kokoro/steps/hostinfo.sh new file mode 100755 index 0000000..a4c34f2 --- /dev/null +++ b/.github/kokoro/steps/hostinfo.sh @@ -0,0 +1,51 @@ +#!/bin/bash +# -*- coding: utf-8 -*- +# +# Copyright 2020 Regents of the University of California +# +# 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 + +echo +echo "========================================" +echo "Host Environment" +echo "----------------------------------------" +export +echo "----------------------------------------" + +echo +echo "========================================" +echo "Host CPU" +echo "----------------------------------------" +export CORES=$(nproc --all) +echo "Cores: $CORES" +echo +echo "Memory" +echo "----------------------------------------" +cat /proc/meminfo +echo "----------------------------------------" +export MEM_GB=$(($(awk '/MemTotal/ {print $2}' /proc/meminfo)/(1024*1024))) +echo "Memory (GB): $CORES" +export MEM_CORES=$(($MEM_GB/4)) + +echo +echo "========================================" +echo "Package version" +echo "----------------------------------------" +set -x +gcc --version +set +x +echo "----------------------------------------" diff --git a/.github/kokoro/steps/hostsetup.sh b/.github/kokoro/steps/hostsetup.sh new file mode 100755 index 0000000..8caa377 --- /dev/null +++ b/.github/kokoro/steps/hostsetup.sh @@ -0,0 +1,45 @@ +#!/bin/bash +# -*- coding: utf-8 -*- +# +# Copyright 2020 Regents of the University of California +# +# 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 + +echo +echo "========================================" +echo "Host updating packages" +echo "----------------------------------------" +sudo apt-get update +echo "----------------------------------------" + +echo +echo "========================================" +echo "Host install packages" +echo "----------------------------------------" +sudo apt-get install -y \ + bash \ + build-essential \ + ca-certificates \ + colordiff \ + coreutils \ + git \ + m4 \ + make \ + psmisc \ + wget + + echo "----------------------------------------"