-
Notifications
You must be signed in to change notification settings - Fork 52
91 lines (77 loc) · 2.67 KB
/
Copy pathcrds.yaml
File metadata and controls
91 lines (77 loc) · 2.67 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
name: CRDs
on:
push:
branches:
- develop
pull_request:
workflow_dispatch: {}
permissions:
contents: read
pull-requests: write
env:
CARGO_TERM_COLOR: always
CARGO_INCREMENTAL: 0
CI: 1
CTY_VERSION: 1.1.3
jobs:
diskpool-crds:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: 'recursive'
- uses: cachix/install-nix-action@v31.3.0
- name: Pre-populate nix-shell
run: |
export NIX_PATH=nixpkgs=$(jq '.nixpkgs.url' nix/sources.json -r)
echo "NIX_PATH=$NIX_PATH" >> $GITHUB_ENV
nix-shell --run "echo" shell.nix
- name: Handle Rust dependencies caching
uses: Swatinem/rust-cache@v2
- name: Install cty
run: |
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
ARCH=amd64
echo "Downloading cty v${CTY_VERSION} for ${OS}_${ARCH}"
curl -fsSL https://github.com/Skarlso/crd-to-sample-yaml/releases/download/v${CTY_VERSION}/cty_${OS}_${ARCH}.tar.gz | tar -xz -C /usr/local/bin cty
echo "/usr/local/bin" >> $GITHUB_PATH
/usr/local/bin/cty version
- name: Generate DiskPool CRD
run: nix-shell --run "cargo run --bin operator-diskpool -- --generate-crd --output-dir k8s/crd_test/crds"
- name: Verify DiskPool CRD
run: |
if [ ! -f k8s/crd_test/crds/diskpools.crd.yaml ]; then
echo "DiskPool CRD was not generated correctly"
exit 1
fi
echo "DiskPool CRD was generated successfully"
cat k8s/crd_test/crds/diskpools.crd.yaml
- name: Test CRDs for backwards compatibility
id: crd-test
run: |
# Run cty to test CRDs
/usr/local/bin/cty test k8s/crd_test || {
echo "Validation failed: Breaking changes detected."
exit 1
}
echo "Validation successful: No breaking changes detected."
- name: Add PR comment to update snapshot if required
if: ${{ success() && github.event_name == 'pull_request' }}
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const prNumber = context.payload.pull_request.number;
const body = `
**CRD snapshot files may be out-of-date**
Please update the CRD snapshots by running:
\`\`\`bash
cty test k8s/crd_test --update
\`\`\`
and add updated snapshot to the PR patch.
`;
await github.rest.issues.createComment({
...context.repo,
issue_number: prNumber,
body
})