Add first iteration on CI

Signed-off-by: Víctor Mayoral Vilches <v.mayoralv@gmail.com>
This commit is contained in:
Víctor Mayoral Vilches 2025-01-10 15:10:11 +00:00
parent 3c8496abee
commit 8eef7d7f1e
6 changed files with 106 additions and 1 deletions

3
.gitignore vendored
View File

@ -146,3 +146,6 @@ cai.png
cai.dot
cai*.png
test_20*
# CI
!ci/build/

25
.gitlab-ci.yml Normal file
View File

@ -0,0 +1,25 @@
stages:
- build
- setup
- test # unit tests validation
- ctf-super-easy # "Super easy" CTF challenges coming out of PentestPerf
- ctf-easy # "Easy" CTF challenges coming out of PentestPerf
- ctf-medium # "Medium" CTF challenges coming out of PentestPerf
- ctf-hard # "Hard" CTF challenges coming out of PentestPerf
- ctf-super-hard # "Super hard" CTF challenges coming out of PentestPerf
variables:
DOCKER_HOST: tcp://docker:2375
DOCKER_DRIVER: overlay2
DOCKER_TLS_CERTDIR: ""
VERSION: "0.1"
DISTRO: ubuntu:22.04
include:
- project: 'aliasrobotics/alias_research/cai'
ref: main
file:
- 'ci/build_container/.build.yml' # build
#- 'ci/setup/.setup.yml' # setup
- 'ci/test/.test.yml' # test
#- 'ci/ctfs/.ctf.yml' # ctf

View File

@ -377,8 +377,8 @@ CAI is developed by [Alias Robotics](https://aliasrobotics.com) and funded as pa
- [x] re-organize tools
- [ ] add tests -> Fill up all empty files or remove them
- [x] add tests
- [ ] review agent tests and use pytest utilities (parametrize, etc)
- [ ] CI
- [ ] Tracing
- [ ] Graph/flow and other abstractions
- [ ] Plan/router

48
ci/build/.build.yml Normal file
View File

@ -0,0 +1,48 @@
#
# TEMPLATE:
# The following pieces create containers on the go
# to facilitate reproduction of jobs.
#
.base_attacker_container: &base_attacker_container
stage: build
image: docker:latest
services:
- docker:dind
before_script:
# - echo $CI_JOB_TOKEN | docker login -u gitlab-ci-token --password-stdin $CI_REGISTRY;
- |
for i in $(seq 1 5); do
echo $CI_JOB_TOKEN | docker login -u gitlab-ci-token --password-stdin $CI_REGISTRY_IMAGE && break || sleep 10
echo "Retrying docker login ($i/5)..."
done
- apk add --no-cache docker-compose
script:
- cat .devcontainer/Dockerfile > Dockerfile_base
# Build the image
- docker build -t $CI_REGISTRY_IMAGE:$TAGGING -f Dockerfile_base .
- docker push $CI_REGISTRY_IMAGE:$TAGGING
#
# JOB:
# A job to create the base container image for the attacker
# in x86_64.
#
# NOTE: Enable only if base container needs to be rebuilt.
# this will typically be the case whenever we change
# .devcontainer/Dockerfile
#
🚧 base_attacker_container:
variables:
TAGGING: latest
<<: *base_attacker_container
tags: # local runners won't have the right configuration
- p40
- x86
rules:
- if: '$CI_COMMIT_BRANCH'
changes:
- .devcontainer/Dockerfile
- ci/build/**/*
when: on_success
- when: never

29
ci/test/.test.yml Normal file
View File

@ -0,0 +1,29 @@
.use_base_container: &use_base_container
stage: test
image: "${CI_REGISTRY_IMAGE}:latest"
services:
- name: docker:dind
.run_test: &run_test
<<: *use_base_container
script:
- pip3 install -e .
- pytest $TEST_PATH -s
tags:
- p40
- x86
rules:
- if: $CI_COMMIT_BRANCH
when: on_success
🏗️ tools reconnaissance/filesystem:
<<: *run_test
variables:
TEST_PATH: tests/tools/reconnaissance/test_filesystem.py
# 🏗️ tools test_list_dir:
# <<: *run_test
# variables:
# TEST_PATH: tests/tests/tools/reconnaissance/filesystem/list_dir.py