Skip to content

Build

Build #1

Workflow file for this run

name: "Build"
on:
workflow_call:
inputs:
ref:
description: "the git revision to checkout"
default: ${{github.ref}}
required: false
type: string
outputs:
artifact-name:
description: "artifacts name"
value: ${{ jobs.build.outputs.artifact-name }}
artifact-link:
description: "artifacts link"
value: ${{ jobs.build.outputs.artifact-link }}
secrets:
ARTIFACTS_USER:
required: true
ARTIFACTS_PASSWORD:
required: true
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-20.04
outputs:
artifact-name: ${{ steps.upload.outputs.name }}
artifact-link: ${{ steps.upload.outputs.link }}
steps:
- name: Cleanup some unused ressources
# Because of the large number of images we embed in the ISO
# the disk space available start to be a problem.
# Let's remove some unused ressources to free some space.
run: |-
sudo rm -rf /usr/local/lib/android
sudo rm -rf /usr/share/dotnet
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ inputs.ref }}
# NOTE: We fetch depth so that we can put the right `GIT` reference
# in the product.txt
fetch-depth: 0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Install Python 3
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: setup cache for pip
uses: actions/cache@v4
env:
cache-name: pip-packages
with:
path: ~/.cache/pip/
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('buildchain/requirements.txt') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Install deps
run: |
export DEBIAN_FRONTEND=noninteractive
sudo apt-get update
sudo apt-get install --no-install-recommends -y \
genisoimage \
isomd5sum \
hardlink
- name: Build everything
run: ./doit.sh -n 4 --verbosity 2 --failure-verbosity 2
- name: Prepare artifacts
env:
DEST_DIR: "artifacts"
ARTIFACTS: >-
build.log
_build/metalk8s.iso
_build/SHA256SUM
_build/root/product.txt
run: |
mkdir -p "$DEST_DIR"
for artifact in $ARTIFACTS; do
cp -r "$artifact" "$DEST_DIR"
done
- name: Upload artifacts
id: upload
uses: scality/action-artifacts@v4
with:
method: upload
url: https://artifacts.scality.net
user: ${{ secrets.ARTIFACTS_USER }}
password: ${{ secrets.ARTIFACTS_PASSWORD }}
source: artifacts
- name: Cleanup build tree
run: ./doit.sh clean && test ! -d _build
build-shell-ui:
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ inputs.ref }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Compute shell-ui version
run: |
source VERSION
echo "SHELL_UI_VERSION=$VERSION_MAJOR.$VERSION_MINOR.$VERSION_PATCH$VERSION_SUFFIX" >> $GITHUB_ENV
- name: Build shell-ui container image
run: docker build . --tag shell-ui:v$SHELL_UI_VERSION
working-directory: shell-ui
- name: Extract shell folder from shell-ui container
run: |
docker create --name shell-ui shell-ui:v$SHELL_UI_VERSION
docker cp shell-ui:/usr/share/nginx/html/shell .
docker rm shell-ui
tar cvf shell.tar shell
- name: Save shell-ui container image
run: >
docker save shell-ui:v$SHELL_UI_VERSION |
gzip > shell-ui.tar.gz
- name: Prepare artifacts
run: mkdir -p "artifacts/images" && mv shell-ui.tar.gz artifacts/images/ && mv shell.tar artifacts/images/
- name: Upload artifacts
uses: scality/action-artifacts@v4
with:
method: upload
url: https://artifacts.scality.net
user: ${{ secrets.ARTIFACTS_USER }}
password: ${{ secrets.ARTIFACTS_PASSWORD }}
source: artifacts
docs:
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ inputs.ref }}
- name: Install Python 3
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install deps
run: |
export DEBIAN_FRONTEND=noninteractive
sudo apt-get update
sudo apt-get install --no-install-recommends -y plantuml
python3.10 -m pip install tox~=4.0.19
- name: Build documentation for ReadTheDocs
env:
# Fake that we are building in a ReadTheDocs environment
READTHEDOCS: "True"
run: tox --workdir /tmp/tox -e docs -- html
- name: Copy generated docs for ReadTheDocs
run: mkdir -p artifacts/docs/readthedocs && cp -r docs/_build/* artifacts/docs/readthedocs/
- name: Build documentation with Scality theme
run: rm -rf docs/_build && tox --workdir /tmp/tox -e docs -- html
- name: Copy generated docs with Scality theme
run: cp -r docs/_build/* artifacts/docs/ && cp CHANGELOG.md artifacts/docs/
- name: Upload artifacts
uses: scality/action-artifacts@v4
with:
method: upload
url: https://artifacts.scality.net
user: ${{ secrets.ARTIFACTS_USER }}
password: ${{ secrets.ARTIFACTS_PASSWORD }}
source: artifacts
lint:
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ inputs.ref }}
- name: Install Python 3
uses: actions/setup-python@v5
with:
python-version: "3.10"
# NOTE: Today python3.6 is needed by some lint steps
- name: Install Python 3.6
uses: actions/setup-python@v5
with:
python-version: "3.6"
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: "1.20.14"
- name: Install deps
run: |
export DEBIAN_FRONTEND=noninteractive
sudo apt-get update
sudo apt-get install --no-install-recommends -y shellcheck python2.7-minimal
python3.10 -m pip install tox~=4.0.11
- name: Install Helm
env:
HELM_VERSION: "3.10.0"
run: |
sudo curl -O https://get.helm.sh/helm-v${HELM_VERSION}-linux-amd64.tar.gz \
&& sudo tar -zxvf helm-v${HELM_VERSION}-linux-amd64.tar.gz \
&& sudo mv linux-amd64/helm /usr/local/bin/helm
- name: Run all linting targets
run: ./doit.sh lint
unit_tests_ui:
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ inputs.ref }}
- name: Install node
uses: actions/setup-node@v4
with:
node-version: "16"
- name: Cache node modules
id: cache-npm
uses: actions/cache@v4
env:
cache-name: cache-node-modules
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Install UI dependencies
run: |
cd ui
npm ci --prefer-offline --no-audit --legacy-peer-deps --unsafe-perm --no-optional
- name: Run all UI unit tests
run: |
cd ui
npm run test:nowatch --no-update-notifier
- name: Prepare artifacts
run: mkdir -p "artifacts/ui" && mv ui/junit artifacts/ui/
- name: Upload artifacts
uses: scality/action-artifacts@v4
with:
method: upload
url: https://artifacts.scality.net
user: ${{ secrets.ARTIFACTS_USER }}
password: ${{ secrets.ARTIFACTS_PASSWORD }}
source: artifacts
unit_tests_shell_ui:
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ inputs.ref }}
- name: Install node
uses: actions/setup-node@v4
with:
node-version: "16"
- name: Cache node modules
id: cache-npm
uses: actions/cache@v4
env:
cache-name: cache-node-modules
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Install UI dependencies
run: |
cd shell-ui
npm ci --prefer-offline --no-audit --legacy-peer-deps -d
- name: Run all Shell UI unit tests
run: |
cd shell-ui
npm run test --no-update-notifier
unit_tests_crd_client_generator:
runs-on: ubuntu-20.04
defaults:
run:
working-directory: "tools/crd-client-generator-js"
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ inputs.ref }}
- name: Install node
uses: actions/setup-node@v4
with:
node-version: "16"
- name: Cache node modules
uses: actions/cache@v4
env:
cache-name: cache-node-modules
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Install CRD client generator dependencies
run: npm ci --prefer-offline --no-audit
- name: Run all CRD client generator unit tests
run: npm run test --no-update-notifier
unit_tests_metalk8s_operator:
runs-on: ubuntu-20.04
defaults:
run:
working-directory: "operator"
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ inputs.ref }}
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: "1.20.14"
- name: Cache Go modules
uses: actions/cache@v4
env:
cache-name: cache-go-modules
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('go.sum') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Run all MetalK8s operator unit and integration tests
run: make test
unit_tests_storage_operator:
runs-on: ubuntu-20.04
defaults:
run:
working-directory: "storage-operator"
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ inputs.ref }}
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: "1.20.14"
- name: Cache Go modules
uses: actions/cache@v4
env:
cache-name: cache-go-modules
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('go.sum') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Run all storage-operator unit and integration tests
run: make test
unit_tests_salt:
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ inputs.ref }}
- name: Install Python 3.6
uses: actions/setup-python@v5
with:
python-version: "3.6"
- name: Install deps
run: |
pip install tox
- name: Run all salt unit tests
run: tox -e unit-tests
unit_tests_lib_alert_tree:
runs-on: ubuntu-20.04
defaults:
run:
working-directory: "tools/lib-alert-tree"
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ inputs.ref }}
- name: Install Python 3
uses: actions/setup-python@v5
with:
python-version: "3.6"
- name: Install deps
run: python3.6 -m pip install poetry~=1.1.9
- name: Install lib_alert_tree
run: poetry install -E cli
- name: Run all lib_alert_tree unit tests
run: poetry run pytest -vv
build_integration_container_nginx:
runs-on: ubuntu-20.04
permissions: write-all
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ inputs.ref }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Install node
uses: actions/setup-node@v4
with:
node-version: "16"
- name: Cache node modules
id: cache-npm
uses: actions/cache@v4
env:
cache-name: cache-node-modules
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Install Shell UI dependencies
run: |
cd shell-ui
npm ci --legacy-peer-deps
- name: Build Shell UI
run: |
cd shell-ui
npm run build
- name: Install UI dependencies
run: |
cd ui
npm ci --legacy-peer-deps --no-optional
- name: Build UI
run: |
cd ui
npm run build
- name: Prepare Services Volumes
run: |
mkdir -p service
mkdir -p service/shell
cp -r ui/build/* service/
cp -r ui/build/.well-known service/.well-known
cp -r shell-ui/build/* service/shell/
- name: Build container with nginx configuration for integration tests
run: |
cat > Dockerfile <<EOF
FROM nginx:alpine
COPY ui/standalone-nginx.conf /etc/nginx/conf.d/default.conf
ADD service /usr/share/nginx/html
EOF
- name: Login to Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/build-push-action@v5
with:
push: true
file: Dockerfile
context: .
tags: ghcr.io/${{ github.repository_owner }}/metalk8s-nginx-integration-tests:${{ github.sha }}
integration_tests_ui:
runs-on: ubuntu-20.04
needs:
- build_integration_container_nginx
services:
app:
image: ghcr.io/${{ github.repository_owner }}/metalk8s-nginx-integration-tests:${{ github.sha }}
credentials:
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
ports:
- 80:80
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ inputs.ref }}
- name: Install node
uses: actions/setup-node@v4
with:
node-version: "16"
- name: Cache node modules
id: cache-npm
uses: actions/cache@v4
env:
cache-name: cache-node-modules
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Install Cypress and its dependencies
run: |
cd ui
PKGS="har-validator cypress cypress-cucumber-preprocessor cypress-wait-until @testing-library/cypress"
for pkg in $PKGS; do
npm install --no-save --no-package-lock --legacy-peer-deps $pkg@$(node -p \
-e "require('./package-lock.json').dependencies['$pkg'].version" \
) || exit 1
done
- name: Wait for application to be available
run: |
bash -c '
attempts=0
until curl -Isfo /dev/null http://localhost/; do
(( attempts++ ))
if [ $attempts -gt 100 ]; then
>&2 echo "Failed to reach application after 5 minutes"
exit 1
fi
sleep 3
done
'
- name: Run all UI integration tests
env:
CYPRESS_BASE_URL: http://localhost
run: |
cd ui
rm -rf babel.config.js
npm run test:integration --no-update-notifier
- name: Prepare upload folder
if: always()
run: |
mkdir -p upload/ui/cypress
mv ui/cypress/screenshots upload/ui/cypress/screenshots || true
mv ui/cypress/videos upload/ui/cypress/videos || true
mv junit upload/ui || true
- name: Upload artifacts
if: always()
uses: scality/action-artifacts@v4
with:
method: upload
url: https://artifacts.scality.net
user: ${{ secrets.ARTIFACTS_USER }}
password: ${{ secrets.ARTIFACTS_PASSWORD }}
source: upload
write-final-failed-status:
runs-on: ubuntu-20.04
needs:
- build
- build-shell-ui
- docs
- lint
- unit_tests_ui
- unit_tests_shell_ui
- unit_tests_crd_client_generator
- unit_tests_metalk8s_operator
- unit_tests_storage_operator
- unit_tests_salt
- unit_tests_lib_alert_tree
- integration_tests_ui
if: failure()
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{inputs.ref}}
- name: write failure status
run: |
mkdir -p artifacts
echo -n "FAILED" > artifacts/.final_status
- name: Upload artifacts
uses: scality/action-artifacts@v4
with:
method: upload
url: https://artifacts.scality.net
user: ${{ secrets.ARTIFACTS_USER }}
password: ${{ secrets.ARTIFACTS_PASSWORD }}
source: artifacts
write-final-success-status:
runs-on: ubuntu-20.04
needs:
- build
- build-shell-ui
- docs
- lint
- unit_tests_ui
- unit_tests_shell_ui
- unit_tests_crd_client_generator
- unit_tests_metalk8s_operator
- unit_tests_storage_operator
- unit_tests_salt
- unit_tests_lib_alert_tree
- integration_tests_ui
if: success()
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{inputs.ref}}
- name: write failure status
run: |
mkdir -p artifacts
echo -n "SUCCESSFUL" > artifacts/.final_status
- name: Upload artifacts
uses: scality/action-artifacts@v4
with:
method: upload
url: https://artifacts.scality.net
user: ${{ secrets.ARTIFACTS_USER }}
password: ${{ secrets.ARTIFACTS_PASSWORD }}
source: artifacts