-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace nix with a devcontainer #556
Merged
Merged
Changes from all commits
Commits
Show all changes
41 commits
Select commit
Hold shift + click to select a range
80fae38
First working container
jorg-vr cf2d028
Use dockerfile instead of container
jorg-vr 3966213
make devconatiner buildable from commandline
jorg-vr b88e879
Try usage in ci tests
jorg-vr 0324e76
Only build container once in ci
jorg-vr 6c4cbeb
Fix no steps issue
jorg-vr 4fb3a39
Never push after run
jorg-vr e065c28
Run typecheck through poetry
jorg-vr ee81097
Add pyright as a poetry dev dependency
jorg-vr b13f122
Update poetry lock
jorg-vr 4264b98
Use script
jorg-vr fae17da
Cleanup docker file
jorg-vr 13a297b
Get rid of poetry
jorg-vr 889afd8
Readd hlint to docker
jorg-vr fd50222
Restructure dockerfile
jorg-vr 5eb9762
Fix csharp
jorg-vr c71d12d
Add test variables to path
jorg-vr 9dfe146
Add git in dev container
jorg-vr 1a12e0b
Run js integration test in dev container
jorg-vr 82cde43
Fix env variable
jorg-vr 96add3c
Avoid double build
jorg-vr 6c929f4
Try different exercise repo
jorg-vr 31e966a
Remove poetry and nix
jorg-vr 9c9bdca
Add pytest marks to toml
jorg-vr 17e60f2
Readd jinja
jorg-vr 7902101
Readd dependencies for description converter
jorg-vr 69d6c0a
Update pyright version to version without issues
jorg-vr 3aff7c8
Update readme
jorg-vr be9fd9b
Add dependabot.yml
jorg-vr adf160c
Add build docker workflow
jorg-vr cafaa45
Update .devcontainer/devcontainer.json
jorg-vr 4ce18af
Add script to automatically create a pr
jorg-vr d3cdb4f
Merge branch 'chore/devcontainer' of github.com:dodona-edu/universal-…
jorg-vr ac1d0a4
No recursion needed in copy
jorg-vr afa8187
Test run action
jorg-vr 0001991
Separate git clone flags
jorg-vr c5ddb77
Simplify folder
jorg-vr 3c5b332
Simplify sed approach
jorg-vr 3f8f633
Setup username and email
jorg-vr e0669ce
Add user and email
jorg-vr abc1ee5
Improve header
jorg-vr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/bin/bash | ||
|
||
# Install dev dependencies | ||
pip install --no-cache-dir --upgrade \ | ||
pytest==8.2.1 \ | ||
pytest-mock==3.14.0 \ | ||
pytest-cov==5.0.0 \ | ||
pytest-xdist==3.6.1 \ | ||
syrupy==4.6.1 \ | ||
black==24.4.2 \ | ||
isort==5.13.2 \ | ||
pyright==1.1.365 | ||
|
||
|
||
# Install dependencies for the description generator | ||
pip install --no-cache-dir --upgrade \ | ||
jinja2==3.1.4\ | ||
marko==2.0.3 | ||
|
||
# add installed packages to path | ||
cat <<EOF >> /home/runner/.bashrc | ||
export PATH=$PATH:/home/runner/.local/bin | ||
EOF |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"name": "dodona-tested", | ||
"build": { | ||
"dockerfile": "dodona-tested.dockerfile", | ||
"context": "." | ||
}, | ||
"postCreateCommand": "./.devcontainer/dev-dependencies.sh", | ||
"features" : { | ||
// add git to the container | ||
"ghcr.io/devcontainers/features/git:1": { | ||
"version": "latest" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
# This is the Dockerfile for the tested judge. | ||
# It can be downloaded using docker pull dodona/dodona-tested. | ||
|
||
# This docker image is run in our production environment. | ||
# It should not contain any development tools or dependencies. | ||
# Add those to dev-dependencies.sh instead. | ||
|
||
FROM python:3.12.4-slim-bullseye | ||
|
||
# Set up the environment | ||
|
||
# Kotlin | ||
ENV SDKMAN_DIR /usr/local/sdkman | ||
ENV PATH $SDKMAN_DIR/candidates/kotlin/current/bin:$PATH | ||
ENV PATH $SDKMAN_DIR/candidates/java/current/bin:$PATH | ||
# Haskell | ||
ENV HASKELL_DIR /usr/local/ghcupdir | ||
ENV PATH $HASKELL_DIR/ghc/bin:$PATH | ||
ENV PATH $HASKELL_DIR/cabal:$PATH | ||
# Node | ||
ENV NODE_PATH /usr/lib/node_modules | ||
|
||
# Install dependencies | ||
RUN <<EOF | ||
# Update apt-get | ||
apt-get update | ||
|
||
# Install general dependencies | ||
apt-get install -y --no-install-recommends \ | ||
procps \ | ||
dos2unix \ | ||
curl \ | ||
zip \ | ||
unzip | ||
|
||
# Python dependencies | ||
pip install --no-cache-dir --upgrade \ | ||
psutil==5.9.8 \ | ||
attrs==23.2.0 \ | ||
cattrs==23.2.3 \ | ||
jsonschema==4.22.0 \ | ||
typing_inspect==0.9.0 \ | ||
pyyaml==6.0.1 \ | ||
Pygments==2.18.0 \ | ||
python-i18n==0.3.9 \ | ||
pylint==3.0.1 | ||
|
||
# C/C++ dependencies | ||
apt-get install -y --no-install-recommends \ | ||
gcc \ | ||
cppcheck | ||
|
||
# Bash dependencies | ||
apt-get install -y --no-install-recommends \ | ||
bc \ | ||
binutils \ | ||
bsdmainutils \ | ||
cowsay \ | ||
ed \ | ||
figlet \ | ||
file \ | ||
toilet \ | ||
tree \ | ||
vim \ | ||
xxd \ | ||
shellcheck | ||
|
||
# Haskell dependencies | ||
apt-get install -y --no-install-recommends \ | ||
hlint \ | ||
autoconf \ | ||
build-essential \ | ||
zlib1g-dev \ | ||
libgmp-dev | ||
bash -c "set -o pipefail && curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | BOOTSTRAP_HASKELL_NONINTERACTIVE=1 BOOTSTRAP_HASKELL_MINIMAL=1 sh" | ||
bash -c "source /root/.ghcup/env && ghcup install ghc 9.6 --isolate $HASKELL_DIR/ghc" | ||
bash -c "source /root/.ghcup/env && ghcup install cabal --isolate $HASKELL_DIR/cabal" | ||
cabal update | ||
cabal v1-install --global aeson | ||
|
||
# JavaScript dependencies | ||
bash -c 'set -o pipefail && curl -fsSL https://deb.nodesource.com/setup_22.x | bash -' | ||
apt-get install -y --no-install-recommends nodejs | ||
npm install -g [email protected] [email protected] | ||
|
||
# C# dependencies | ||
curl https://packages.microsoft.com/config/debian/11/packages-microsoft-prod.deb --output packages-microsoft-prod.deb | ||
dpkg -i packages-microsoft-prod.deb | ||
rm packages-microsoft-prod.deb | ||
apt-get update | ||
apt-get install -y --no-install-recommends dotnet-sdk-8.0 | ||
|
||
# Java and Kotlin dependencies | ||
bash -c 'set -o pipefail && curl -s "https://get.sdkman.io?rcupdate=false" | bash' | ||
chmod a+x "$SDKMAN_DIR/bin/sdkman-init.sh" | ||
bash -c "source \"$SDKMAN_DIR/bin/sdkman-init.sh\" && sdk install java 21.0.3-tem && sdk install kotlin" | ||
curl -sSLO https://github.com/pinterest/ktlint/releases/download/1.2.1/ktlint | ||
chmod a+x ktlint | ||
mv ktlint /usr/local/bin | ||
|
||
# Java specific dependencies | ||
apt-get install -y --no-install-recommends checkstyle | ||
|
||
# Clean up apt caches | ||
apt-get clean | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
# Setup permissions and user | ||
chmod 711 /mnt | ||
useradd -m runner | ||
mkdir /home/runner/workdir | ||
chown -R runner:runner /home/runner/workdir | ||
EOF | ||
|
||
USER runner | ||
WORKDIR /home/runner/workdir | ||
|
||
COPY main.sh /main.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/bin/sh | ||
|
||
# kill all child processes on exit | ||
trap "pkill -P $$" EXIT | ||
|
||
"$1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: docker | ||
directory: "/" | ||
schedule: | ||
interval: monthly | ||
time: "13:00" | ||
timezone: Europe/Brussels | ||
open-pull-requests-limit: 99 | ||
- package-ecosystem: "devcontainers" | ||
directory: ".github/workflows" | ||
schedule: | ||
interval: monthly | ||
time: "13:00" | ||
timezone: Europe/Brussels | ||
open-pull-requests-limit: 99 |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# this file is used to build the devcontainer image and push it to the docker registry | ||
# it is used to speed up other ci jobs by using the prebuilt image | ||
# this does not create the production image, as that should only be done when merging to main | ||
name: 'Build devcontainer' | ||
on: | ||
workflow_call: | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
|
||
- name: Checkout (GitHub) | ||
uses: actions/checkout@v3 | ||
|
||
- name: Login to Docker Container Registry | ||
uses: docker/login-action@v2 | ||
with: | ||
username: ${{ secrets.DOCKER_USERNAME }} | ||
password: ${{ secrets.DOCKER_PASSWORD }} | ||
|
||
- name: Build and run Dev Container task | ||
uses: devcontainers/[email protected] | ||
with: | ||
imageName: dodona/dodona-tested | ||
imageTag: dev |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,46 +5,97 @@ on: | |
pull_request_target: | ||
types: [labeled] | ||
|
||
env: | ||
EXERCISES_COMMIT: 31ef0f174efaeba2a37415115e7fd0332573d9b2 | ||
|
||
jobs: | ||
test: | ||
build_devcontainer: | ||
if: ${{ github.event.action != 'labeled' || (github.event.action == 'labeled' && github.event.label.name == 'run tests') }} | ||
uses: ./.github/workflows/build_devcontainer.yml | ||
secrets: inherit | ||
test: | ||
needs: [build_devcontainer] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ github.event.pull_request.head.ref }} | ||
repository: ${{ github.event.pull_request.head.repo.full_name }} | ||
- uses: DeterminateSystems/nix-installer-action@main | ||
- uses: DeterminateSystems/magic-nix-cache-action@main | ||
- run: echo "${GITHUB_WORKSPACE}" >> $GITHUB_PATH | ||
- run: nix build .#simple-tests --print-build-logs | ||
- name: Run tests in container | ||
uses: devcontainers/[email protected] | ||
with: | ||
imageName: dodona/dodona-tested | ||
imageTag: dev | ||
push: never | ||
runCmd: pytest -n auto --cov=tested --cov-report=xml tests/ | ||
- name: Upload coverage to Codecov | ||
uses: codecov/codecov-action@v4 | ||
with: | ||
token: ${{ secrets.CODECOV_TOKEN }} | ||
files: ./result/coverage.xml | ||
lint: | ||
if: ${{ github.event.action != 'labeled' || (github.event.action == 'labeled' && github.event.label.name == 'run tests') }} | ||
needs: [build_devcontainer] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ github.event.pull_request.head.ref }} | ||
repository: ${{ github.event.pull_request.head.repo.full_name }} | ||
- uses: DeterminateSystems/nix-installer-action@main | ||
- uses: DeterminateSystems/magic-nix-cache-action@main | ||
- run: echo "${GITHUB_WORKSPACE}" >> $GITHUB_PATH | ||
- run: nix develop .#format -c poetry run isort --check-only --diff ./tested ./tests | ||
- run: nix develop .#format -c poetry run black --check ./tested ./tests | ||
- name: Run isort | ||
uses: devcontainers/[email protected] | ||
with: | ||
imageName: dodona/dodona-tested | ||
imageTag: dev | ||
push: never | ||
runCmd: isort --check-only --diff ./tested ./tests | ||
- name: Run black | ||
uses: devcontainers/[email protected] | ||
with: | ||
imageName: dodona/dodona-tested | ||
imageTag: dev | ||
push: never | ||
runCmd: black --check ./tested ./tests | ||
types: | ||
if: ${{ github.event.action != 'labeled' || (github.event.action == 'labeled' && github.event.label.name == 'run tests') }} | ||
needs: [build_devcontainer] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ github.event.pull_request.head.ref }} | ||
repository: ${{ github.event.pull_request.head.repo.full_name }} | ||
- uses: DeterminateSystems/nix-installer-action@main | ||
- uses: DeterminateSystems/magic-nix-cache-action@main | ||
- run: echo "${GITHUB_WORKSPACE}" >> $GITHUB_PATH | ||
- run: nix develop .#types -c pyright ./tested ./tests | ||
- name: Run pyright | ||
uses: devcontainers/[email protected] | ||
with: | ||
imageName: dodona/dodona-tested | ||
imageTag: dev | ||
push: never | ||
runCmd: pyright ./tested ./tests | ||
# check if the JS exercises still work. | ||
javascript-dodona: | ||
needs: [build_devcontainer] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ github.event.pull_request.head.ref }} | ||
repository: ${{ github.event.pull_request.head.repo.full_name }} | ||
- run: | | ||
echo "$JAVASCRIPT_EXERCISES_KEY" > private | ||
chmod 0600 private | ||
GIT_SSH_COMMAND='ssh -o "StrictHostKeyChecking no" -i private' git clone [email protected]:Scriptingtalen/javascript-oefeningen.git | ||
rm private | ||
env: | ||
JAVASCRIPT_EXERCISES_KEY: ${{ secrets.JAVASCRIPT_EXERCISES_KEY }} | ||
- run: git checkout $EXERCISES_COMMIT | ||
working-directory: ./javascript-oefeningen | ||
- name: Run tests in container | ||
uses: devcontainers/[email protected] | ||
env: | ||
EXERCISE_REPO: javascript-oefeningen | ||
with: | ||
imageName: dodona/dodona-tested | ||
imageTag: dev | ||
push: never | ||
runCmd: pytest -x -n auto tests/test_integration_javascript.py | ||
env: | | ||
EXERCISE_REPO |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will create only a single layer in the file system? If so, I think going forward our other images can also adopt this style instead of adding everything to a single command. It is much more readable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes this only creates a single layer. And I approve of this.