From 1073447e73a4e8ae9dad027f082aeb9fe28be3a1 Mon Sep 17 00:00:00 2001 From: Alya Sirko Date: Sat, 10 Sep 2022 16:52:54 +0300 Subject: [PATCH] add ci pipeline --- .drone.yml | 33 ++++++++++++++++++--------------- ci.py | 23 +++++++++++++++++------ 2 files changed, 35 insertions(+), 21 deletions(-) diff --git a/.drone.yml b/.drone.yml index 20bbeb51..ba24a23f 100644 --- a/.drone.yml +++ b/.drone.yml @@ -1,18 +1,21 @@ -#kind: pipeline -#type: exec -#name: Continuous Integration -# -#steps: -# -#trigger: -# event: -# - push -# - pull_request -# -#node: -# server: builder -# -#--- +kind: pipeline +type: exec +name: Continuous Integration + +steps: + - name: Build + commands: + - ./ci.py --run-ci-build + +trigger: + event: + - push + - pull_request + +node: + server: builder + +--- kind: pipeline type: exec diff --git a/ci.py b/ci.py index 2f3aaea9..9f5627d6 100755 --- a/ci.py +++ b/ci.py @@ -35,6 +35,12 @@ def podman_online(dir, *args): CONTAINER_IMAGE, "bash", "-c", ' '.join(args) ]) +def podman_ci(dir, *args): + subprocess.run(["podman", "run", "-it", "--rm", "--privileged", f"--workdir={dir}", + "-v", os.getcwd() + f":{CONTAINER_HOME}/src:U", + CONTAINER_IMAGE, "bash", "-c", ' '.join(args) + ]) + # Targets def build_linux(): @@ -85,12 +91,14 @@ def deploy_gitea_release(): "--asset", f"{HOST_MOUNTED_VOLUME}/{APP_NAME}-{APP_SEMVER}.tar.zstd"]) def deploy_fdroid_repo(): -# subprocess.run(["eval $(ssh-agent -s)"], shell=True) -# subprocess.run(["echo \"$SSH_PRIVATE_KEY\" | tr -d '\r' | ssh-add -"], shell=True) -# subprocess.run(["scp", "-oStrictHostKeyChecking=no", "-oUserKnownHostsFile=/dev/null", -# "-r", f"{HOST_HOME}/fdroid/repo/*", -# "deployer@selfprivacy.org:/var/www/fdroid.selfprivacy.org"]) - subprocess.run([f"eval $(ssh-agent -s) && echo \"$SSH_PRIVATE_KEY\" | tr -d '\r' | ssh-add - && scp -oStrictHostKeyChecking=no -oUserKnownHostsFile=/dev/null -r {HOST_HOME}/fdroid/repo/* deployer@selfprivacy.org:/var/www/fdroid.selfprivacy.org"], shell=True) + subprocess.run([f"""eval $(ssh-agent -s) && + echo \"$SSH_PRIVATE_KEY\" | tr -d '\r' | ssh-add - && + scp -oStrictHostKeyChecking=no -oUserKnownHostsFile=/dev/null -r {HOST_HOME}/fdroid/repo/* deployer@selfprivacy.org:/var/www/fdroid.selfprivacy.org + """], shell=True) + +def run_ci_build(): + podman_ci(f"{CONTAINER_HOME}/src", "flutter build linux --debug") + podman_ci(f"{CONTAINER_HOME}/src", "flutter build apk --debug") # Arguments @@ -106,6 +114,7 @@ if __name__ == "__main__": group.add_argument("--package-linux-archive", action="store_true") group.add_argument("--deploy-gitea-release", action="store_true") group.add_argument("--deploy-fdroid-repo", action="store_true") + group.add_argument("--run-ci-build", action="store_true") args = parser.parse_args() if args.build_linux: @@ -126,3 +135,5 @@ elif args.deploy_gitea_release: deploy_gitea_release() elif args.deploy_fdroid_repo: deploy_fdroid_repo() +elif args.run_ci_build: + run_ci_build()