forked from ComposableFi/composable
-
Notifications
You must be signed in to change notification settings - Fork 0
119 lines (115 loc) · 4.37 KB
/
persistent-devnet.yml
File metadata and controls
119 lines (115 loc) · 4.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
name: Persistent Devnet
on:
workflow_dispatch:
inputs:
ref:
description: "Release tag, branch name or any other ref."
required: true
type: string
# Following is disabled to allow manual upgrade to run data migrations by QA in staging
# push:
# tags:
# - 'release-v[0-9]+\.[0-9]+'
env:
NIX_NIXPKGS_CHANNEL: https://nixos.org/channels/nixpkgs-22.05-darwin
CACHIX_COMPOSABLE: composable-community
CACHIX_COMPRESSION_LEVEL: 3
NIXOPS_STATE_URL: gs://composable-state
NIXOPS_STATE_FILE: persistent.deployment.nixops
jobs:
cache:
name: "Cache"
runs-on:
- self-hosted
- x64-cute
concurrency:
group: cache-${{ matrix.package }}
cancel-in-progress: true
strategy:
matrix:
package: [devnet-dali-persistent, devnet-picasso-persistent]
container:
image: niteo/nixpkgs-nixos-22.05:316b762afdb9e142a803f29c49a88b4a47db80ee
steps:
- uses: actions/checkout@v3
with:
ref: ${{ inputs.ref || github.sha }}
fetch-depth: 0
- run: |
echo "experimental-features = nix-command flakes" > /etc/nix/nix.conf
echo "sandbox = relaxed" >> /etc/nix/nix.conf
echo "narinfo-cache-negative-ttl = 0" >> /etc/nix/nix.conf
- uses: cachix/cachix-action@f5f67badd061acb62b5c6e25e763572ca8317004
with:
skipPush: true
installCommand: |
nix-channel --add ${{ env.NIX_NIXPKGS_CHANNEL }} nixpkgs
nix-channel --update
nix-env -iA nixpkgs.cachix
authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
name: ${{ env.CACHIX_COMPOSABLE }}
- name: "Build & Upload"
run: |
cachix watch-exec --jobs 16 --compression-level $CACHIX_COMPRESSION_LEVEL composable-community nix -- build .#${{ matrix.package }} --no-update-lock-file --show-trace -L
deploy:
needs: cache
name: "Deploy Persistent Devnet"
runs-on:
- self-hosted
- x64-cute
concurrency:
group: nix-deploy-devnet-persistent
cancel-in-progress: false
container:
image: niteo/nixpkgs-nixos-22.05:316b762afdb9e142a803f29c49a88b4a47db80ee
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- run: |
echo "experimental-features = nix-command flakes" > /etc/nix/nix.conf
echo "sandbox = relaxed" >> /etc/nix/nix.conf
echo "narinfo-cache-negative-ttl = 0" >> /etc/nix/nix.conf
- uses: cachix/cachix-action@f5f67badd061acb62b5c6e25e763572ca8317004
with:
skipPush: true
installCommand: |
nix-channel --add ${{ env.NIX_NIXPKGS_CHANNEL }} nixpkgs
nix-channel --update
nix-env -iA nixpkgs.cachix
authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
name: ${{ env.CACHIX_COMPOSABLE }}
- uses: google-github-actions/setup-gcloud@v0.6.0
with:
service_account_key: ${{ secrets.GCP_CREDENTIALS }}
export_default_credentials: true
credentials_file_path: ${{ runner.temp }}/credentials
- name: Install NixOps
run: |
nix-env -iA nixpkgs.nixopsUnstable
- name: Load NixOps State
run: |
if gsutil -q stat $NIXOPS_STATE_URL/$NIXOPS_STATE_FILE;
then
gsutil cp $NIXOPS_STATE_URL/$NIXOPS_STATE_FILE $NIXOPS_STATE
else
nixops create --deployment devnet-gce --show-trace --option narinfo-cache-negative-ttl 0
fi
env:
NIXOPS_STATE: ${{ runner.temp }}/${{ env.NIXOPS_STATE_FILE }}
- name: Deploy
run: |
mkdir -p /root/.ssh
echo "Host *\n\tStrictHostKeyChecking no" > /root/.ssh/config
nixops ssh picasso-composable-persistent-devnet -vvv -o PasswordAuthentication=no -o StrictHostKeyChecking=no || true
nixops ssh composable-persistent-devnet -vvv -o PasswordAuthentication=no -o StrictHostKeyChecking=no || true
nixops deploy --allow-recreate --allow-reboot --confirm --deployment devnet-gce --debug --show-trace --option narinfo-cache-negative-ttl 0 --include composable-persistent-devnet picasso-composable-persistent-devnet
env:
NIXOPS_STATE: ${{ runner.temp }}/${{ env.NIXOPS_STATE_FILE }}
DEPLOY_REVISION: ${{ inputs.ref || github.sha }}
- name: Save NixOps State
if: always()
run: |
gsutil cp $NIXOPS_STATE $NIXOPS_STATE_URL/$NIXOPS_STATE_FILE
env:
NIXOPS_STATE: ${{ runner.temp }}/${{ env.NIXOPS_STATE_FILE }}