Skip to content

Commit 1757c94

Browse files
author
7908837174
committed
1024
1 parent 265dabb commit 1757c94

File tree

6 files changed

+115
-4
lines changed

6 files changed

+115
-4
lines changed

.devcontainer/Dockerfile

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ FROM ubuntu:24.04
22

33
ENV DEBIAN_FRONTEND=noninteractive
44

5+
# Create a non-root user
6+
RUN useradd -m -s /bin/bash vscode
7+
58
WORKDIR /workspace
69

710
RUN export DEBIAN_FRONTEND=noninteractive
@@ -15,6 +18,7 @@ RUN \
1518
clang-format \
1619
clang-tidy \
1720
cmake \
21+
curl \
1822
ditaa \
1923
g++ \
2024
gcc-riscv64-linux-gnu \
@@ -38,8 +42,13 @@ RUN \
3842
ruby-dev \
3943
shellcheck
4044

45+
# Fix PEP 668 issue by using --break-system-packages flag
46+
RUN pip3 install --break-system-packages -r /workspace/requirements.txt
47+
4148
RUN apt-get clean autoclean
4249
RUN apt-get autoremove -y
4350
RUN rm -rf /var/lib/{apt,dpkg,cache,log}/*
4451

45-
WORKDIR /workspace
52+
# Switch to non-root user
53+
USER vscode
54+
WORKDIR /home/vscode

.devcontainer/onCreateCommand.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
#!/bin/bash
22

33
npm i
4-
bundle install
4+
bundle install --verbose
5+
6+
# Install Python packages with --break-system-packages flag to avoid PEP 668 error
7+
pip3 install --break-system-packages -r requirements.txt
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
#!/bin/bash
22

3-
bundle
3+
bundle install --verbose
4+
5+
# Install Python packages with --break-system-packages flag to avoid PEP 668 error
6+
pip3 install --break-system-packages -r requirements.txt
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Container Tests
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- '.devcontainer/**'
7+
- 'docker-compose.yml'
8+
- 'start-dev.sh'
9+
- 'tests/**'
10+
push:
11+
branches:
12+
- main
13+
paths:
14+
- '.devcontainer/**'
15+
- 'docker-compose.yml'
16+
- 'start-dev.sh'
17+
- 'tests/**'
18+
19+
jobs:
20+
test:
21+
runs-on: ubuntu-latest
22+
strategy:
23+
matrix:
24+
proxy: ['with-proxy', 'no-proxy']
25+
steps:
26+
- uses: actions/checkout@v4
27+
28+
- name: Set up test environment
29+
run: |
30+
if [ "${{ matrix.proxy }}" = "with-proxy" ]; then
31+
echo "Setting up test proxy"
32+
export http_proxy="http://localhost:3128"
33+
export https_proxy="http://localhost:3128"
34+
docker run -d --name squid-proxy -p 3128:3128 ubuntu/squid
35+
fi
36+
37+
- name: Run container tests
38+
run: |
39+
chmod +x tests/container_tests.sh
40+
./tests/container_tests.sh
41+
42+
- name: Test VS Code integration
43+
run: |
44+
# Skip this test for now as it's not essential for the build
45+
echo "Skipping VS Code integration test"

Gemfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ gem "idl_highlighter", path: "tools/ruby-gems/idl_highlighter"
88
gem "udb_helpers", path: "tools/ruby-gems/udb_helpers"
99
gem "udb", path: "tools/ruby-gems/udb"
1010

11-
source "https://rubygems.org"
11+
source 'https://rubygems.org'
12+
13+
gem 'bundler'
14+
gem 'rake'
1215

1316
# gem "activesupport"
1417
gem "asciidoctor-diagram", "~> 2.2"

tests/container_tests.sh

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/bin/bash
2+
3+
# SPDX-License-Identifier: BSD-2-Clause
4+
# SPDX-FileCopyrightText: Copyright (c) 2025 RISC-V International
5+
6+
# Container tests script for riscv-unified-db
7+
8+
set -e
9+
10+
echo "Running container tests..."
11+
12+
# Test 1: Check if we can build the container
13+
echo "Test 1: Building container..."
14+
docker build -t riscv-unified-db-test .devcontainer/
15+
16+
# Test 2: Check if we can run basic commands in the container
17+
echo "Test 2: Running basic commands in container..."
18+
docker run --rm riscv-unified-db-test ruby --version
19+
docker run --rm riscv-unified-db-test python3 --version
20+
docker run --rm riscv-unified-db-test npm --version
21+
22+
# Test 3: Check if we can install Python packages
23+
echo "Test 3: Installing Python packages..."
24+
docker run --rm -v $(pwd):/workspace riscv-unified-db-test pip3 install --break-system-packages -r /workspace/requirements.txt
25+
26+
# Test 4: Check if we can install gems
27+
echo "Test 4: Installing gems..."
28+
docker run --rm riscv-unified-db-test gem list bundler
29+
30+
# Test 5: Check if we can run rake tasks
31+
echo "Test 5: Running rake tasks..."
32+
docker run --rm -v $(pwd):/workspace riscv-unified-db-test rake --version
33+
34+
# Test 6: Check non-root user exists
35+
echo "Test 6: Checking non-root user..."
36+
docker run --rm riscv-unified-db-test id -u vscode
37+
38+
# Test 7: Proxy configuration test
39+
echo "Test 7: Checking proxy configuration..."
40+
if [ -n "$http_proxy" ] || [ -n "$https_proxy" ]; then
41+
echo "Proxy is configured: HTTP_PROXY=$http_proxy, HTTPS_PROXY=$https_proxy"
42+
# Test proxy connectivity if configured
43+
docker run --rm -e http_proxy -e https_proxy riscv-unified-db-test env | grep -i proxy
44+
else
45+
echo "No proxy configured"
46+
fi
47+
48+
echo "All container tests passed!"

0 commit comments

Comments
 (0)