Skip to content

ci: run on arm cncf runners #792

ci: run on arm cncf runners

ci: run on arm cncf runners #792

Workflow file for this run

name: CRDs
on:
push:
branches:
- develop
- 'release/**'
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:
relevant-changes:
runs-on: ubuntu-latest
outputs:
relevant: ${{ steps.filter.outputs.relevant }}
steps:
- uses: actions/checkout@v7
with:
submodules: 'recursive'
- name: Detect relevant changes
id: filter
if: github.event_name == 'pull_request'
uses: dorny/paths-filter@v4
with:
filters: |
relevant:
- 'k8s/operators/**'
- 'k8s/crd_test/**'
diskpool-crds:
needs: ["relevant-changes"]
if: |
github.event_name != 'pull_request' ||
needs.relevant-changes.outputs.relevant == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
submodules: 'recursive'
- name: Setup Nix Environment
uses: ./.github/actions/setup-nix
with:
preFetchNix: ./shell.nix
github_access_token: ${{ secrets.GITHUB_TOKEN }}
rust_cache: true
- 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' && github.event.pull_request.head.repo.fork == false }}
uses: actions/github-script@v9
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
})