commit a894b55fc4a326c5db54355739874a6c4612f9a1
parent 74d840a16756756ff87890f614020c1a440abf39
Author: arjoonn <arjoonn@noreply.localhost>
Date: Fri, 10 Feb 2023 12:56:34 +0000
User system docker instead of installing docker inside jci container (!38)
Branch auto created by JayporeCI
```jayporeci
╔ 🟢 : JayporeCI [sha 77eae1ba66]
┏━ build_and_test
┃
┃ 🟢 : JciEnv [f8abdf65] 0:41
┃ 🟢 : Jci [fe09b2a7] 0: 9 ❮-- ['JciEnv']
┃ 🟢 : black [da53d5fc] 0: 0 ❮-- ['JciEnv']
┃ 🟢 : pylint [bee9424a] 0:11 ❮-- ['JciEnv']
┃ 🟢 : pytest [09ae77fc] 0: 3 65% ❮-- ['JciEnv']
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
┏━ Publish
┃
┃ 🟢 : DockerHubJci [87507438] 3: 5
┃ 🟢 : DockerHubJcienv [323b00d4] 2:20
┃ 🟢 : PublishDocs [8fa50561] 0:41
┃ 🟢 : PublishPypi [3f759916] 0: 7
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
```
Co-authored-by: arjoonn sharma <arjoonn@midpathsoftware.com>
Reviewed-on: https://gitea.midpathsoftware.com/midpath/jaypore_ci/pulls/38
Diffstat:
7 files changed, 56 insertions(+), 18 deletions(-)
diff --git a/Dockerfile b/Dockerfile
@@ -1,25 +1,17 @@
-from python:3.11 as jcibase
+from python:3.11 as jcienv
workdir /app
-run apt-get update
-run apt-get install ca-certificates curl zip gnupg lsb-release vim -y
-run mkdir -p /etc/apt/keyrings
-run curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg
-run echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian $(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null
-run apt-get update
-run apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin tree -y
-
-from jcibase as jcienv
run python3 -m pip install --upgrade pip
run python3 -m pip install poetry
add pyproject.toml .
add poetry.lock .
-run poetry export --with dev > req.txt
-run python3 -m pip install -r req.txt
+run poetry config virtualenvs.create false
+run poetry install
env PYTHONPATH=/jaypore_ci/run/:/app
env PATH=/jaypore_ci/run/:/app:$PATH
-run wget -O /bin/sops https://github.com/mozilla/sops/releases/download/v3.7.3/sops-v3.7.3.linux
-run wget -O ./age.tar.gz https://github.com/FiloSottile/age/releases/download/v1.0.0/age-v1.0.0-linux-amd64.tar.gz
+add https://github.com/mozilla/sops/releases/download/v3.7.3/sops-v3.7.3.linux /bin/sops
+add https://github.com/FiloSottile/age/releases/download/v1.0.0/age-v1.0.0-linux-amd64.tar.gz ./age.tar.gz
run tar xf ./age.tar.gz && mv ./age/age /bin && mv ./age/age-keygen /bin && rm -rf ./age
+run apt update && apt install -y wget curl zip
run chmod u+x /bin/sops /bin/age /bin/age-keygen
from jcienv as jci
diff --git a/README.md b/README.md
@@ -1,5 +1,8 @@
# Jaypore CI
+
+
+
Documentation is at : https://www.jayporeci.in
## If you are reading this on github
diff --git a/cicd/pre-push.sh b/cicd/pre-push.sh
@@ -30,7 +30,8 @@ hook() {
# Then we will run git clean to remove anything that is not in git
# Then we call the actual cicd code
#
- # We also pass docker.sock to the run so that jaypore_ci can create docker containers
+ # We also pass docker.sock and the docker executable to the run so that
+ # jaypore_ci can create docker containers
echo '----------------------------------------------'
echo "JayporeCi: "
docker run \
@@ -38,6 +39,7 @@ hook() {
--name jayporeci__pipe__$SHA \
-e JAYPORE_CODE_DIR=$JAYPORE_CODE_DIR \
-e SHA=$SHA \
+ -v /usr/bin/docker:/usr/bin/docker:ro \
-v /var/run/docker.sock:/var/run/docker.sock \
-v $REPO_ROOT:/jaypore_ci/repo:ro \
-v /tmp/jayporeci__src__$SHA:/jaypore_ci/run \
diff --git a/docs/source/index.rst b/docs/source/index.rst
@@ -351,10 +351,8 @@ would test and make sure that jobs are running in order.
p.job(name, name)
order = pipeline.executor.get_execution_order()
- # assert order == {}
assert order["x"] < order["y"] < order["z"]
-
Contributing
============
diff --git a/jaypore_ci/executors/docker.py b/jaypore_ci/executors/docker.py
@@ -149,6 +149,7 @@ class Docker(Executor):
trigger = [
"docker run -d",
"-v /var/run/docker.sock:/var/run/docker.sock",
+ "-v /usr/bin/docker:/usr/bin/docker:ro",
f"-v /tmp/jayporeci__src__{self.pipeline.remote.sha}:/jaypore_ci/run",
*["--workdir /jaypore_ci/run" if not job.is_service else None],
f"--name {self.get_job_name(job)}",
diff --git a/jaypore_ci/jci.py b/jaypore_ci/jci.py
@@ -26,6 +26,48 @@ FIN_STATUSES = (Status.FAILED, Status.PASSED, Status.TIMEOUT, Status.SKIPPED)
PREFIX = "JAYPORE_"
+class Repo:
+ """
+ Contains information about the current repo.
+ """
+
+ sha: str
+ branch: str
+ remote: str
+
+ def files_changed(self, target):
+ "Returns list of files changed between current sha and target"
+ return (
+ subprocess.check_output(
+ f"git diff --name-only {target} {self.sha}", shell=True
+ )
+ .decode()
+ .strip()
+ .split("\n")
+ )
+
+ @classmethod
+ def from_env(cls):
+ remote = (
+ subprocess.check_output(
+ "git remote -v | grep push | awk '{print $2}'", shell=True
+ )
+ .decode()
+ .strip()
+ )
+ assert "https://" in remote, "Only https remotes supported"
+ assert ".git" in remote
+ branch = (
+ subprocess.check_output(
+ r"git branch | grep \* | awk '{print $2}'", shell=True
+ )
+ .decode()
+ .strip()
+ )
+ sha = subprocess.check_output("git rev-parse HEAD", shell=True).decode().strip()
+ return Repo(sha=sha, branch=branch, remote=remote)
+
+
class Job: # pylint: disable=too-many-instance-attributes
"""
This is the fundamental building block for running jobs.
diff --git a/pyproject.toml b/pyproject.toml
@@ -1,6 +1,6 @@
[tool.poetry]
name = "jaypore_ci"
-version = "0.2.6"
+version = "0.2.7"
description = ""
authors = ["arjoonn sharma <arjoonn.94@gmail.com>"]