Restructure CI:

build ISO on each push to main branch

tags with v* and t* names trigger a test VM

pull requests trigger a basic check building host PubSolarOS
This commit is contained in:
teutat3s 2022-08-14 20:51:56 +02:00
parent 8be1bd53d3
commit 472560e1c1
Signed by: teutat3s
GPG key ID: 4FA1D3FA524F22C1

View file

@ -1,92 +1,3 @@
---
kind: pipeline
type: docker
name: Upstreaming
steps:
- name: "Sync 'devos' branch with upstream"
image: alpine/git
when:
event:
- cron
cron:
- sync-main-with-upstream
environment:
GITEA_SSH_KEY:
from_secret: gitea_ssh_key
commands:
- ./.drone/setup_ssh.sh
- git remote add devos git@git.b12f.io:pub-solar/devos
- git remote set-url origin git@git.b12f.io:pub-solar/os
- git fetch --all
- git checkout -b devos --track origin/devos
- git merge -X theirs devos/main
- git push origin devos
- git remote set-url origin https://git.b12f.io/pub-solar/os.git
- name: "Sync $BRANCH with upstream"
image: alpine/git
when:
event:
- cron
cron:
- sync-main-with-upstream
- sync-b12f-with-main
- sync-teutat3s-with-main
environment:
GITEA_SSH_KEY:
from_secret: gitea_ssh_key
commands:
- git fetch origin
- git checkout origin/main
- ./.drone/setup_ssh.sh
- git remote set-url origin git@git.b12f.io:pub-solar/os
- git fetch --all
- ./.drone/upstream-branch.sh
- name: "Open pull request for failed merge"
image: nixery.dev/shell/tea
when:
status:
- failure
event:
- cron
cron:
- sync-main-with-upstream
- sync-b12f-with-main
- sync-teutat3s-with-main
environment:
TEA_CONFIG:
from_secret: tea_config
commands:
- mkdir -p ~/.config/tea
- echo "$$TEA_CONFIG" > ~/.config/tea/config.yml
- tea pulls create --base main --head devos
- name: "Notify matrix"
image: plugins/matrix
when:
status:
- failure
event:
- cron
cron:
- sync-main-with-upstream
- sync-b12f-with-main
- sync-teutat3s-with-main
settings:
homeserver: https://matrix.pub.solar
roomid: dfQBqwkhIzrFjMSsxy:pub.solar
username:
from_secret: matrix_username
password:
from_secret: matrix_password
template: "Upstreaming {{ build.status }} [{{ build.branch }}#{{ truncate build.commit 8 }}]({{ build.link }}) by {{ build.author }}. [Pull requests](https://git.b12f.io/pub-solar/os/pulls)"
trigger:
event:
- cron
--- ---
kind: pipeline kind: pipeline
type: docker type: docker
@ -98,11 +9,11 @@ steps:
when: when:
event: event:
- pull_request - pull_request
- tag
environment: environment:
NIX_FLAGS: "--print-build-logs --verbose" NIX_FLAGS: "--print-build-logs --verbose"
commands: commands:
- 'echo DEBUG: Using NIX_FLAGS: $NIX_FLAGS' - 'echo DEBUG: Using NIX_FLAGS: $NIX_FLAGS'
- nix $$NIX_FLAGS flake show
- nix $$NIX_FLAGS build ".#nixosConfigurations.PubSolarOS.config.system.build.toplevel" - nix $$NIX_FLAGS build ".#nixosConfigurations.PubSolarOS.config.system.build.toplevel"
- nix $$NIX_FLAGS develop --command echo OK - nix $$NIX_FLAGS develop --command echo OK
@ -113,18 +24,19 @@ name: Tests
steps: steps:
- name: "Tests" - name: "Tests"
when:
event:
- pull_request
- tag
environment: environment:
NIX_FLAGS: "--print-build-logs --verbose" NIX_FLAGS: "--print-build-logs --verbose"
commands: commands:
- 'echo DEBUG: Using NIX_FLAGS: $NIX_FLAGS' - 'echo DEBUG: Using NIX_FLAGS: $NIX_FLAGS'
- nix $$NIX_FLAGS build ".#checks.x86_64-linux.customTestFor-PubSolarOS-firstTest" - nix $$NIX_FLAGS build ".#checks.x86_64-linux.customTestFor-PubSolarOS-firstTest"
#- nix $$NIX_FLAGS flake check - nix-store --read-log result
#- nix $$NIX_FLAGS develop --command echo OK - nix $$NIX_FLAGS flake check
#- nix $$NIX_FLAGS develop --command bud --help - nix $$NIX_FLAGS develop --command echo OK
trigger:
ref:
- refs/tags/v*
- refs/tags/t*
--- ---
kind: pipeline kind: pipeline
@ -134,14 +46,15 @@ name: Publish ISO
steps: steps:
- name: "Build ISO" - name: "Build ISO"
image: docker.nix-community.org/nixpkgs/nix-flakes:latest image: docker.nix-community.org/nixpkgs/nix-flakes:latest
environment:
NIX_FLAGS: "--print-build-logs --verbose"
volumes: volumes:
- name: file-exchange - name: file-exchange
path: /var/nix/iso-cache path: /var/nix/iso-cache
commands: commands:
- | - |
nix --print-build-logs --verbose \ nix $$NIX_FLAGS build \
build \ '.#nixosConfigurations.bootstrap.config.system.build.bootstrapIso'
'.#nixosConfigurations.bootstrap.config.system.build.bootstrapIso'
- cp $(readlink -f result)/iso/*.iso /var/nix/iso-cache/ - cp $(readlink -f result)/iso/*.iso /var/nix/iso-cache/
- name: "Publish ISO" - name: "Publish ISO"
@ -167,8 +80,10 @@ depends_on:
- Check - Check
trigger: trigger:
branch:
- main
event: event:
- tag - push
volumes: volumes:
- name: file-exchange - name: file-exchange
@ -176,6 +91,6 @@ volumes:
--- ---
kind: signature kind: signature
hmac: da951ba8ede88996728acfb47846e01880eb0e3b91f66e47848d6c1cc727c5d9 hmac: f78042286446a0649b61bdd28240caf7650cf995804acb714b92d145fa028bdf
... ...