add ci pipeline

This commit is contained in:
Alya Sirko 2022-09-10 16:52:54 +03:00
parent d369e05082
commit 1073447e73
2 changed files with 35 additions and 21 deletions

View file

@ -1,18 +1,21 @@
#kind: pipeline kind: pipeline
#type: exec type: exec
#name: Continuous Integration name: Continuous Integration
#
#steps: steps:
# - name: Build
#trigger: commands:
# event: - ./ci.py --run-ci-build
# - push
# - pull_request trigger:
# event:
#node: - push
# server: builder - pull_request
#
#--- node:
server: builder
---
kind: pipeline kind: pipeline
type: exec type: exec

23
ci.py
View file

@ -35,6 +35,12 @@ def podman_online(dir, *args):
CONTAINER_IMAGE, "bash", "-c", ' '.join(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 # Targets
def build_linux(): def build_linux():
@ -85,12 +91,14 @@ def deploy_gitea_release():
"--asset", f"{HOST_MOUNTED_VOLUME}/{APP_NAME}-{APP_SEMVER}.tar.zstd"]) "--asset", f"{HOST_MOUNTED_VOLUME}/{APP_NAME}-{APP_SEMVER}.tar.zstd"])
def deploy_fdroid_repo(): def deploy_fdroid_repo():
# subprocess.run(["eval $(ssh-agent -s)"], shell=True) subprocess.run([f"""eval $(ssh-agent -s) &&
# subprocess.run(["echo \"$SSH_PRIVATE_KEY\" | tr -d '\r' | ssh-add -"], shell=True) echo \"$SSH_PRIVATE_KEY\" | tr -d '\r' | ssh-add - &&
# subprocess.run(["scp", "-oStrictHostKeyChecking=no", "-oUserKnownHostsFile=/dev/null", scp -oStrictHostKeyChecking=no -oUserKnownHostsFile=/dev/null -r {HOST_HOME}/fdroid/repo/* deployer@selfprivacy.org:/var/www/fdroid.selfprivacy.org
# "-r", f"{HOST_HOME}/fdroid/repo/*", """], shell=True)
# "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) 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 # Arguments
@ -106,6 +114,7 @@ if __name__ == "__main__":
group.add_argument("--package-linux-archive", action="store_true") group.add_argument("--package-linux-archive", action="store_true")
group.add_argument("--deploy-gitea-release", action="store_true") group.add_argument("--deploy-gitea-release", action="store_true")
group.add_argument("--deploy-fdroid-repo", 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() args = parser.parse_args()
if args.build_linux: if args.build_linux:
@ -126,3 +135,5 @@ elif args.deploy_gitea_release:
deploy_gitea_release() deploy_gitea_release()
elif args.deploy_fdroid_repo: elif args.deploy_fdroid_repo:
deploy_fdroid_repo() deploy_fdroid_repo()
elif args.run_ci_build:
run_ci_build()