Skip to content

Commit

Permalink
chore: fix a bug that cmdx t doesn't test packages (#22760)
Browse files Browse the repository at this point in the history
* chore: revert #22718

* chore: fix scripts

* chore: stop setting AQUA_ROOT_DIR

* ci: add a workflow for debug
  • Loading branch information
suzuki-shunsuke committed May 11, 2024
1 parent 7f2969c commit d01ec64
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 31 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/debug-with-action-tmate.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
name: Debug with action-tmate
on:
workflow_dispatch:
inputs:
runs-on:
required: false
default: windows-latest
pr_number:
required: false
ref:
required: false
permissions: {}
jobs:
action-tmate:
runs-on: ${{inputs.runs-on}}
steps:
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
with:
ref: ${{inputs.ref}}

- run: gh pr checkout "${{inputs.pr_number}}"
if: inputs.pr_number != ''
env:
GITHUB_TOKEN: ${{github.token}}
- uses: aquaproj/aqua-installer@6ce1f8848ec8e61f14d57bd5d7597057a6dd187c # v3.0.1
with:
aqua_version: v2.28.0
env:
AQUA_GITHUB_TOKEN: ${{github.token}}

# The default vim doesn't work well, so we install the latest vim ourselves.
- uses: rhysd/action-setup-vim@4b2071ab35df2f10bfbed2a1fdb33be3466455d8 # v1.3.2

- uses: mxschmitt/action-tmate@1005f9c9db5f1b055a495e72c6e589764984baf6 # v3.14
with:
limit-access-to-actor: true # SSH Key is required
env:
GITHUB_TOKEN: ${{github.token}} # Pass GitHub Token to shell session
16 changes: 4 additions & 12 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,26 +1,18 @@
FROM golang:1.22.3-bookworm@sha256:c2caf8c1c462dfa1cb58a7e8eb3e942d4013a90f42ad4ed2ac2517b37ed4bb8c
WORKDIR /workspace
ENV AQUA_LOG_COLOR=always
ENV AQUA_POLICY_CONFIG=/workspace/aqua-policy.yaml
ENV PATH=/root/.local/share/aquaproj-aqua/bin:/root/.cargo/bin:$PATH
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
RUN \
apt-get update && \
apt-get install --no-install-recommends -y tree && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
ARG USERNAME=root
ARG GROUPNAME=root
ARG HOME=/root
RUN (id -u $USERNAME || useradd -m $USERNAME) && \
(getent group $GROUPNAME || groupadd $GROUPNAME)
USER $USERNAME
WORKDIR $HOME
ENV AQUA_ROOT_DIR=$HOME/aquaproj-aqua
ENV AQUA_LOG_COLOR=always
ENV AQUA_POLICY_CONFIG=$HOME/aqua-policy.yaml
ENV PATH=$AQUA_ROOT_DIR/bin:$HOME/.cargo/bin:$PATH
RUN curl -sSfL -O https://raw.githubusercontent.com/aquaproj/aqua-installer/v3.0.1/aqua-installer
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable --profile minimal
RUN echo "fb4b3b7d026e5aba1fc478c268e8fbd653e01404c8a8c6284fdba88ae62eda6a aqua-installer" | sha256sum -c
RUN chmod +x aqua-installer
RUN ./aqua-installer -v v2.28.0
COPY aqua-test.yaml aqua.yaml
COPY aqua-policy.yaml aqua-policy.yaml
WORKDIR /workspace
7 changes: 1 addition & 6 deletions scripts/build_image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,7 @@

set -eu

opts=""
if [ "$(uname)" = Linux ]; then
opts="--build-arg USERNAME=$(id -u -n) --build-arg GROUPNAME=$(id -g -n) --build-arg HOME=/home/$(id -u -n)"
fi

cp aqua-policy.yaml docker
docker build -t aquaproj/aqua-registry $opts docker
docker build -t aquaproj/aqua-registry docker
mkdir -p .build
cp docker/Dockerfile .build
6 changes: 1 addition & 5 deletions scripts/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,7 @@ if [ "$(uname)" = Linux ] && docker version | grep -q Podman; then
opts="--privileged"
fi

if [ "$(uname)" = Linux ]; then
opts+=" -u $(id -u -n):$(id -g -n) -v /etc/passwd:/etc/passwd:ro -v /etc/group:/etc/group:ro"
fi

# shellcheck disable=SC2086
docker run $opts -d --name "$container_name" \
-v "$PWD:/aqua-registry" $envs aquaproj/aqua-registry \
$envs aquaproj/aqua-registry \
tail -f /dev/null
13 changes: 5 additions & 8 deletions scripts/scaffold.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,6 @@ pkg=$1
cmd=$2
limit=$3

if [ -d "pkgs/$pkg" ]; then
rm -R "pkgs/$pkg"
fi

docker exec -ti -w /aqua-registry aqua-registry aqua policy allow
docker exec -ti -w /aqua-registry aqua-registry aqua i -l

opts=""
if [ -n "$cmd" ]; then
opts="-cmd $cmd"
Expand All @@ -22,4 +15,8 @@ if [ -n "$limit" ]; then
fi

# shellcheck disable=SC2086
docker exec -ti -w /aqua-registry aqua-registry aqua-registry scaffold $opts "$pkg"
docker exec -ti -w /workspace aqua-registry bash -c "rm pkg.yaml || :"
docker exec -ti -w /workspace aqua-registry bash -c "aqua gr $opts --out-testdata pkg.yaml \"$pkg\" > registry.yaml"
mkdir -p "pkgs/$pkg"
docker cp "aqua-registry:/workspace/pkg.yaml" "pkgs/$pkg/pkg.yaml"
docker cp "aqua-registry:/workspace/registry.yaml" "pkgs/$pkg/registry.yaml"
1 change: 1 addition & 0 deletions scripts/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ docker cp "pkgs/$pkg/registry.yaml" "$container_name:/workspace/registry.yaml"

for os in linux darwin; do
for arch in amd64 arm64; do
docker exec "$container_name" bash -c "rm aqua-checksums.json || :"
if ! docker exec "$container_name" env AQUA_GOOS="$os" AQUA_GOARCH="$arch" aqua i; then
echo "[ERROR] Build failed $os/$arch" >&2
docker exec -ti "$container_name" env AQUA_GOOS="$os" AQUA_GOARCH="$arch" bash
Expand Down

0 comments on commit d01ec64

Please sign in to comment.