Skip to content

Commit 8d78190

Browse files
committed
Merge remote-tracking branch 'origin/w/129.0/improvement/update-github-actions-runners' into w/130.0/improvement/update-github-actions-runners
2 parents b62d812 + 31eda42 commit 8d78190

22 files changed

+303
-202
lines changed

.devcontainer/Dockerfile

Lines changed: 44 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM mcr.microsoft.com/devcontainers/base:jammy
1+
FROM mcr.microsoft.com/devcontainers/base:noble
22

33
RUN export DEBIAN_FRONTEND=noninteractive && \
44
apt-get update && \
@@ -7,10 +7,12 @@ RUN export DEBIAN_FRONTEND=noninteractive && \
77
bash-completion \
88
build-essential \
99
curl \
10+
docker.io \
1011
enchant-2 \
1112
gawk \
1213
gcc \
1314
genisoimage \
15+
gh \
1416
git \
1517
isomd5sum \
1618
libassuan-dev \
@@ -24,7 +26,6 @@ RUN export DEBIAN_FRONTEND=noninteractive && \
2426
npm \
2527
pkg-config \
2628
plantuml \
27-
python3.10-gdbm \
2829
shellcheck \
2930
tk-dev \
3031
tmux \
@@ -36,20 +37,54 @@ RUN export DEBIAN_FRONTEND=noninteractive && \
3637

3738
USER vscode
3839

40+
ENV LANG=C.UTF-8
41+
ENV LC_ALL=C.UTF-8
42+
43+
# NOTE: Due to a bug in recent babel version, it cannot work with
44+
# default UTC timezone
45+
# See: https://github.com/python-babel/babel/issues/990
46+
RUN sudo ln -fs /usr/share/zoneinfo/UTC /etc/localtime
47+
48+
ENV PYENV_ROOT="/usr/local/pyenv"
49+
ENV PATH="$PYENV_ROOT/shims:$PYENV_ROOT/bin:$PATH"
50+
51+
# Install pyenv
52+
RUN sudo git clone https://github.com/pyenv/pyenv.git $PYENV_ROOT && \
53+
sudo chown $(id -u):$(id -g) -R $PYENV_ROOT && \
54+
printf 'export PYENV_ROOT=%s\nexport PATH="$PYENV_ROOT/shims:$PYENV_ROOT/bin:$PATH"\nif command -v pyenv 1>/dev/null 2>&1; then\n eval "$(pyenv init -)"\nfi\n' $PYENV_ROOT | sudo tee -a /etc/bash.bashrc -a /etc/zsh/zshrc
55+
56+
# Install pythons
57+
RUN pyenv install 3.10.12 3.6.15 2.7 && \
58+
pyenv global 3.10.12 3.6.15 2.7
59+
60+
# Install python libs
61+
RUN pip3 install --no-cache-dir --upgrade pip && \
62+
pip3.6 install --no-cache-dir --upgrade pip && \
63+
pip3 install --no-cache-dir "tox~=4.4.12" "pre-commit~=3.3.3" "virtualenv<20.22.0" "esbonio>=0.12.0" && \
64+
pip3.6 install --no-cache-dir "poetry~=1.1.15" && \
65+
pyenv rehash
66+
3967
# Install helm
40-
ARG HELM_VERSION=3.16.2
68+
ARG HELM_VERSION=3.17.2
4169

4270
RUN curl --fail -L -o /tmp/helm.tar.gz https://get.helm.sh/helm-v${HELM_VERSION}-linux-amd64.tar.gz && \
4371
sudo tar -zxvf /tmp/helm.tar.gz -C /usr/local/bin/ linux-amd64/helm --strip-components 1 && \
4472
rm -rf /tmp/helm.tar.gz
4573

4674
# Install go
4775
ARG GO_VERSION=1.21.13
76+
ENV GOROOT="/usr/local/go"
77+
# NOTE: We use a custom GOPATH so that we can use it both for vscode and root users
78+
ENV GOPATH="/usr/lib/go"
79+
ENV GOBIN="$GOPATH/bin"
80+
ENV PATH="$GOBIN:$GOROOT/bin:$PATH"
4881

4982
RUN curl --fail -L -o /tmp/go.tar.gz https://go.dev/dl/go${GO_VERSION}.linux-amd64.tar.gz && \
50-
sudo tar -C /usr/local -xzf /tmp/go.tar.gz && \
51-
sudo ln -s /usr/local/go/bin/go /usr/local/bin/go && \
52-
sudo ln -s /usr/local/go/bin/gofmt /usr/local/bin/gofmt && \
83+
sudo tar -C /usr/local/ -xzf /tmp/go.tar.gz && \
84+
sudo mkdir -p $GOPATH && \
85+
sudo chown $(id -u):$(id -g) -R $GOROOT $GOPATH && \
86+
cd $GOROOT/bin && mv go go${GO_VERSION} && ln -s go${GO_VERSION} go && \
87+
printf 'export PATH="%s:%s/bin:$PATH"\n' $GOBIN $GOROOT | sudo tee -a /etc/bash.bashrc -a /etc/zsh/zshrc && \
5388
rm -rf /tmp/go.tar.gz
5489

5590
# Install golangci-lint
@@ -59,20 +94,8 @@ RUN curl --fail -L -o /tmp/install.sh https://raw.githubusercontent.com/golangci
5994
sudo bash /tmp/install.sh v${GOLANGCI_VERSION} && \
6095
rm -f /tmp/install.sh
6196

62-
# Install pyenv
63-
RUN git clone https://github.com/pyenv/pyenv.git ~/.pyenv && \
64-
echo 'export PATH="$HOME/.pyenv/bin:$PATH"\nif command -v pyenv 1>/dev/null 2>&1; then\n eval "$(pyenv init -)"\nfi' | tee -a ~/.bashrc -a ~/.zshrc && \
65-
export PATH="$HOME/.pyenv/bin:$PATH" && eval "$(pyenv init -)"
66-
67-
# Install pythons
68-
RUN ~/.pyenv/bin/pyenv install 3.10.12 3.6.15 && \
69-
~/.pyenv/bin/pyenv global 3.10.12 3.6.15
70-
71-
# Install python libs
72-
RUN ~/.pyenv/bin/pyenv exec pip install "tox~=4.4.12" "pre-commit~=3.3.3" "virtualenv<20.22.0" "esbonio>=0.12.0"
73-
74-
# Install crane and gcrane
75-
ARG CRANE_VERSION=0.20.2
97+
# Install crane
98+
ARG CRANE_VERSION=0.20.3
7699

77100
RUN curl --fail -L -o /tmp/crane.tar.gz https://github.com/google/go-containerregistry/releases/download/v${CRANE_VERSION}/go-containerregistry_Linux_x86_64.tar.gz && \
78101
sudo tar -xzf /tmp/crane.tar.gz -C /usr/local/bin/ crane gcrane && \
@@ -84,7 +107,7 @@ ARG SKOPEO_VERSION=1.15.1
84107
RUN curl --fail -L -o /tmp/skopeo.tar.gz https://github.com/containers/skopeo/archive/refs/tags/v${SKOPEO_VERSION}.tar.gz && \
85108
tar -zxvf /tmp/skopeo.tar.gz -C /tmp && \
86109
cd /tmp/skopeo-${SKOPEO_VERSION} && \
87-
sudo make bin/skopeo && \
110+
sudo "PATH=$PATH" make bin/skopeo && \
88111
sudo mv bin/skopeo /usr/local/bin/ && \
89112
cd && \
90113
rm -rf /tmp/skopeo.tar.gz /tmp/skopeo-${SKOPEO_VERSION}

.devcontainer/devcontainer.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
{
22
"name": "metalk8s",
33
"build": {
4-
"dockerfile": "Dockerfile"
4+
"dockerfile": "Dockerfile",
5+
"options": [
6+
"--platform=linux/amd64"
7+
],
8+
"cacheFrom": [
9+
"type=gha,scope=devcontainer"
10+
]
511
},
612
"features": {
713
"ghcr.io/devcontainers/features/sshd:1": {},

.devcontainer/setup.sh

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,7 @@ if [ "$CODESPACES" = "true" ]; then
1313
git reset --hard HEAD
1414
fi
1515

16-
# NOTE: Due to a bug in recent babel version, it cannot work with
17-
# default UTC timezone
18-
# See: https://github.com/python-babel/babel/issues/990
19-
echo "Updating localtime"
20-
sudo ln -fs /usr/share/zoneinfo/UTC /etc/localtime
21-
2216
echo "Install pre-commit hooks"
23-
pre-commit install
17+
pre-commit install --install-hooks
2418

2519
echo "End of setup"

.github/changed-files.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ docs:
99
- tools/lib-alert-tree/**
1010
- tools/rule_extractor/alerting_rules.json
1111
- tox.ini
12+
- .devcontainer/**
1213

1314
shell-ui:
1415
- shell-ui/**
@@ -26,16 +27,20 @@ unit-tests-crd-client-generator:
2627

2728
unit-tests-metalk8s-operator:
2829
- operator/**
30+
- .devcontainer/**
2931

3032
unit-tests-storage-operator:
3133
- storage-operator/**
34+
- .devcontainer/**
3235

3336
unit-tests-salt:
3437
- salt/**
3538
- tox.ini
39+
- .devcontainer/**
3640

3741
unit-tests-lib-alert-tree:
3842
- tools/lib-alert-tree/**
43+
- .devcontainer/**
3944

4045
integration-tests-ui:
4146
- *ui
@@ -74,7 +79,6 @@ build:
7479
- "!solution-operator-lib/**"
7580
# Filter out devX and tools
7681
- "!.pre-commit-config.yaml"
77-
- "!.devcontainer/**"
7882
- "!.gitignore"
7983
- "!LICENSE"
8084
- "!README.md"
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: build devcontainer
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
skip:
7+
type: boolean
8+
required: false
9+
default: false
10+
description: 'Skip the build and publish'
11+
12+
jobs:
13+
build-and-publish-devcontainer:
14+
runs-on: ubuntu-24.04
15+
permissions:
16+
contents: read
17+
packages: write
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v4
21+
- name: Set up Docker Buildx
22+
uses: docker/setup-buildx-action@v3
23+
- name: Login to the registry
24+
uses: docker/login-action@v3
25+
with:
26+
registry: ghcr.io
27+
username: ${{ github.repository_owner }}
28+
password: ${{ secrets.GITHUB_TOKEN }}
29+
- name: Build dev container
30+
# NOTE: We only skip this and not the full Job
31+
# otherwise step that "need" it will not be started
32+
if: ${{ ! inputs.skip }}
33+
uses: docker/build-push-action@v6
34+
with:
35+
context: .devcontainer/
36+
push: true
37+
tags: ghcr.io/${{ github.repository }}/devcontainer:${{ github.sha }}
38+
cache-from: type=gha,scope=devcontainer
39+
cache-to: type=gha,mode=max,scope=devcontainer

.github/workflows/build-docs.yaml

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,30 +8,50 @@ on:
88
default: ${{ github.ref }}
99
required: false
1010
type: string
11+
build-devcontainer:
12+
description: "True will build the devcontainer"
13+
default: true
14+
required: false
15+
type: boolean
1116
secrets:
1217
ARTIFACTS_USER:
1318
required: true
1419
ARTIFACTS_PASSWORD:
1520
required: true
1621

1722
jobs:
23+
build-devcontainer:
24+
uses: ./.github/workflows/build-devcontainer.yaml
25+
secrets: inherit
26+
with:
27+
# NOTE: We check "!= true" instead of just checking the value
28+
# since by default when the workflow is call with "workflow dispatch"
29+
# the input will (sadly) be "" and not use the default value
30+
skip: ${{ inputs.build-devcontainer != true }}
31+
1832
docs:
19-
runs-on: ubuntu-20.04
33+
runs-on: ubuntu-latest
34+
needs:
35+
- build-devcontainer
36+
container:
37+
image: ghcr.io/${{ github.repository }}/devcontainer:${{ github.sha }}
38+
# We have to use `root` for the moment
39+
# Sees: https://github.com/actions/checkout/issues/1575
40+
# Could work with a user with 1001 id but not for docker
41+
options: --user root
42+
credentials:
43+
username: ${{ github.repository_owner }}
44+
password: ${{ secrets.GITHUB_TOKEN }}
45+
defaults:
46+
run:
47+
shell: bash
2048
steps:
2149
- name: Checkout
2250
uses: actions/checkout@v4
2351
with:
2452
ref: ${{ inputs.ref }}
25-
- name: Install Python 3
26-
uses: actions/setup-python@v5
27-
with:
28-
python-version: "3.10"
29-
- name: Install deps
30-
run: |
31-
export DEBIAN_FRONTEND=noninteractive
32-
sudo apt-get update
33-
sudo apt-get install --no-install-recommends -y plantuml
34-
python3.10 -m pip install tox~=4.0.19
53+
- name: Set safe directory (since container is root and not user 1001)
54+
run: git config --global --add safe.directory $GITHUB_WORKSPACE
3555
- name: Build documentation for ReadTheDocs
3656
env:
3757
# Fake that we are building in a ReadTheDocs environment

.github/workflows/build-shell-ui.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ on:
1616

1717
jobs:
1818
shell-ui:
19-
runs-on: ubuntu-20.04
19+
runs-on: ubuntu-24.04
2020
steps:
2121
- name: Checkout
2222
uses: actions/checkout@v4

0 commit comments

Comments
 (0)