Skip to content

Feat: add pipeline callback to local deployment #224

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion localinstall/.env-api
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
SECRET_KEY=b6451545d2e4635148d768f07877aade3ad8e7e160d52962badd7587a4b9a150
#SECRET_KEY=
#algorithm=
#access_token_expire_minutes=
SMTP_HOST=localhost
Expand Down
6 changes: 6 additions & 0 deletions localinstall/1-rebuild_all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,18 @@ failonerror
echo Build docker images: pipeline
./kci docker $args kernelci pipeline --version="$pipeline_rev"
failonerror
echo Build docker images: lava-callback
./kci docker $args kernelci lava-callback --version="$pipeline_rev"
failonerror
echo Tag docker image of api to latest
docker tag local/staging-kernelci:api-$api_rev local/staging-kernelci:api
failonerror
echo Tag docker image of pipeline to latest
docker tag local/staging-kernelci:pipeline-$pipeline_rev local/staging-kernelci:pipeline
failonerror
echo Tag docker image of lava-callback to latest
docker tag local/staging-kernelci:lava-callback-$pipeline_rev local/staging-kernelci:lava-callback
failonerror
echo Build docker images: clang-17+kselftest+kernelci for x86
./kci docker $args clang-17 kselftest kernelci --arch x86
failonerror
Expand Down
2 changes: 2 additions & 0 deletions localinstall/2-install_api.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ cp .env-api kernelci/kernelci-api/.env
cp api-configs.yaml kernelci/kernelci-core/config/core/
cp kernelci-cli.toml kernelci/kernelci-core/kernelci.toml

sed -i "s/#SECRET_KEY=/SECRET_KEY=${API_SECRET_KEY}/" kernelci/kernelci-api/.env

cd kernelci/kernelci-api
mkdir -p docker/redis/data
${SUDO} chmod -R 0777 docker/storage/data
Expand Down
15 changes: 11 additions & 4 deletions localinstall/3-install_pipeline.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ tail -n +$((line+1)) kernelci/kernelci-pipeline/config/pipeline.yaml >> tmp.yaml
mv tmp.yaml kernelci/kernelci-pipeline/config/pipeline.yaml
}

# replace in pipeline.yaml http://172.17.0.1:8001 to http://localhost:8001
sed -i 's/http:\/\/172.17.0.1:8001/http:\/\/host.docker.internal:8001/g' kernelci/kernelci-pipeline/config/pipeline.yaml

# TODO: Check if this is already done
#append_storage

Expand Down Expand Up @@ -52,7 +49,7 @@ sed -i "s|- '/data/kernelci-deploy-checkout/kernelci-pipeline/data/ssh/|- '$PIPE
sed -i "s|- '/data/kernelci-deploy-checkout/kernelci-pipeline/data/output/|- '$PIPELINE_PWD/data/output/|g" config/pipeline.yaml

# set 777 to data/output and data/ssh (TODO: or set proper uid, kernelci is 1000?)
chmod -R 777 data
chmod -R 777 data/output
chmod 777 data/ssh
cp ../../ssh.key data/ssh/id_rsa_tarball
chown 1000:1000 data/ssh/id_rsa_tarball
Expand Down Expand Up @@ -94,3 +91,13 @@ echo "KCI_API_TOKEN=${API_TOKEN}" >> .env
echo "API_TOKEN=${API_TOKEN}" >> .env
cp .env kernelci/kernelci-pipeline/.docker-env
mv .env kernelci/kernelci-pipeline/.env

# Add JWT section with the secret key to kernelci.toml for pipeline callback
sed -i 's/#\[jwt\]$/[jwt]/' kernelci/kernelci-pipeline/config/kernelci.toml
sed -i 's/#secret = "SomeSecretString"/secret = "'"${PIPELINE_SECRET_KEY}"'"/' kernelci/kernelci-pipeline/config/kernelci.toml
# Generate kci-dev token
pip install pyjwt
TOKEN=$(kernelci/kernelci-pipeline/tools/jwt_generator.py --toml kernelci/kernelci-pipeline/config/kernelci.toml \
--email ${YOUR_EMAIL} --permissions checkout,testretry,patchset | grep "JWT token:" | cut -d' ' -f3)
echo $TOKEN > kci-dev-token.txt
echo "kci-dev token saved to kci-dev-token.txt"
1 change: 1 addition & 0 deletions localinstall/4-start-cycle.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ fi
cd kernelci/kernelci-pipeline
${DOCKER_COMPOSE} down
${DOCKER_COMPOSE} up -d

echo "You can view now logs of containers using docker logs -f <container_id> or docker-compose logs -f in kernelci/kernelci-pipeline or kernelci/kernelci-api directories"
echo "Also you can do docker ps to see running containers, and in case of ongoing builds, you can view their logs too by docker logs -f <container_id>"
echo "You can also open API viewer at http://127.0.0.1:8001/viewer"
2 changes: 2 additions & 0 deletions localinstall/main.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ KCI_PIPELINE_BRANCH=staging.kernelci.org
[email protected]
ADMIN_PASSWORD="Ch4n93m3HpL33z"
STORAGE_TOKEN="FKDFLKJFLKDJFLK"
PIPELINE_SECRET_KEY="0123456789"
API_SECRET_KEY="9876543210"
#KCI_CACHE=1