operator: add feature flag to only build CRDs #265
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Build and run tests | |
name: ci (nix) | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
jobs: | |
run_checks: | |
name: run checks | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: checkout sources | |
uses: actions/checkout@v2 | |
- name: install nix | |
uses: cachix/install-nix-action@v20 | |
- name: setup cachix | |
uses: cachix/cachix-action@v12 | |
with: | |
name: apibara-public | |
authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}" | |
- name: run flake check | |
run: nix flake check | |
run_tests: | |
name: run tests | |
runs-on: ubuntu-22.04 | |
needs: | |
- run_checks | |
steps: | |
- name: checkout sources | |
uses: actions/checkout@v2 | |
- name: install nix | |
uses: cachix/install-nix-action@v20 | |
- name: setup cachix | |
uses: cachix/cachix-action@v12 | |
with: | |
name: apibara-public | |
authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}" | |
- name: run build | |
run: nix build .#tests --accept-flake-config | |
- name: run unit tests | |
run: | | |
for testBin in ./result/bin/*; do | |
./${testBin} | |
done | |
- name: run e2e tests | |
run: | | |
for testBin in ./result/bin/*; do | |
./${testBin} --ignored | |
done | |
build_binaries: | |
name: build ${{ matrix.binary }}, target=${{ matrix.job.target }}, os=${{ matrix.job.os }} | |
needs: | |
- run_tests | |
runs-on: ${{ matrix.job.os }} | |
strategy: | |
matrix: | |
binary: | |
- starknet | |
- operator | |
- sink-webhook | |
- sink-mongo | |
- sink-postgres | |
- sink-parquet | |
job: | |
- os: ubuntu-22.04 | |
target: x86_64-unknown-linux-gnu | |
# - os: macos-latest | |
# target: x86_64-apple-darwin | |
steps: | |
- name: checkout sources | |
uses: actions/checkout@v2 | |
- name: install nix | |
uses: cachix/install-nix-action@v20 | |
- name: setup cachix | |
uses: cachix/cachix-action@v12 | |
with: | |
name: apibara-public | |
authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}" | |
- name: build binary ${{ matrix.binary }} | |
run: | | |
if [[ $RUNNER_OS == Linux ]]; then | |
nix build .#${{ matrix.binary }} --accept-flake-config | |
else | |
nix build .#${{ matrix.binary }} --override-input nixpkgs github:nixos/nixpkgs/nixpkgs-22.11-darwin --accept-flake-config | |
fi | |
- name: upload artifacts ${{ matrix.binary }}-${{ matrix.job.target }} | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ matrix.binary }}-${{ matrix.job.target }} | |
path: result/bin/apibara-${{ matrix.binary }} | |
retention-days: 1 | |
build_images: | |
name: build docker image ${{ matrix.image }} | |
runs-on: ubuntu-22.04 | |
needs: | |
- build_binaries | |
strategy: | |
matrix: | |
image: | |
- starknet | |
- operator | |
- sink-webhook | |
- sink-mongo | |
- sink-postgres | |
- sink-parquet | |
steps: | |
- name: checkout sources | |
uses: actions/checkout@v2 | |
- name: install nix | |
uses: cachix/install-nix-action@v20 | |
- name: setup cachix | |
uses: cachix/cachix-action@v12 | |
with: | |
name: apibara-public | |
authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}" | |
- name: build image ${{ matrix.image }} | |
run: nix build .#${{ matrix.image }}-image --accept-flake-config | |
- name: rename image ${{ matrix.image }} | |
run: mv result ${{ matrix.image }}.tar.gz | |
- name: upload artifacts ${{ matrix.image }} | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ matrix.image }}.tar.gz | |
path: ${{ matrix.image }}.tar.gz | |
retention-days: 1 | |
publish_images: | |
name: publish docker image ${{ matrix.image }} | |
if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
runs-on: ubuntu-22.04 | |
needs: build_images | |
strategy: | |
matrix: | |
image: | |
- starknet | |
- operator | |
- sink-webhook | |
- sink-mongo | |
- sink-postgres | |
- sink-parquet | |
steps: | |
- name: login into registry | |
uses: redhat-actions/podman-login@v1 | |
with: | |
username: ${{ secrets.QUAY_USER }} | |
password: ${{ secrets.QUAY_PASSWORD }} | |
registry: quay.io | |
- name: download ${{ matrix.image }} | |
uses: actions/download-artifact@v3 | |
with: | |
name: ${{ matrix.image }}.tar.gz | |
path: . | |
- name: load docker image | |
run: | | |
podman image load --input ${{ matrix.image }}.tar.gz | |
podman image tag localhost/apibara-${{ matrix.image }}:latest ${{ matrix.image }}:${{ github.sha }} | |
podman image ls -a | |
- name: push to registry | |
uses: redhat-actions/push-to-registry@v2 | |
with: | |
image: ${{ matrix.image }} | |
tags: ${{ github.sha }} | |
registry: quay.io/apibara | |
update_preview_release: | |
name: update preview release | |
if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
needs: publish_images | |
runs-on: ubuntu-22.04 | |
permissions: write-all | |
steps: | |
- name: checkout sources | |
uses: actions/checkout@v2 | |
- name: login gh | |
run: gh auth login --with-token < <(echo ${{ secrets.GITHUB_TOKEN }}) | |
- name: delete old version of the release | |
run: gh release delete --yes --repo apibara/apibara preview || true | |
- name: create release | |
run: | | |
gh release create \ | |
--repo apibara/apibara \ | |
--prerelease \ | |
--target ${{ github.sha }} \ | |
--title "Preview" \ | |
--notes "Preview build from the latest `main` commit." \ | |
preview | |
publish_preview_binaries: | |
name: publish preview binaries, binary=${{ matrix.binary }}, target=${{ matrix.target }} | |
if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
needs: update_preview_release | |
runs-on: ubuntu-22.04 | |
permissions: write-all | |
strategy: | |
matrix: | |
binary: | |
- starknet | |
- operator | |
- sink-webhook | |
- sink-mongo | |
- sink-postgres | |
- sink-parquet | |
target: | |
- x86_64-unknown-linux-gnu | |
steps: | |
- name: login gh | |
run: gh auth login --with-token < <(echo ${{ secrets.GITHUB_TOKEN }}) | |
- name: download ${{ matrix.binary }}-${{ matrix.target }} | |
uses: actions/download-artifact@v3 | |
with: | |
name: ${{ matrix.binary }}-${{ matrix.target }} | |
path: . | |
- name: publish artifact | |
run: | | |
ls -la | |
echo ${{ matrix.target }} > .target | |
zip ${{ matrix.binary }}-${{ matrix.target }}.zip apibara-${{ matrix.binary }} .target | |
gh release upload --repo apibara/apibara --clobber preview ${{ matrix.binary }}-${{ matrix.target }}.zip |