Skip to content

Commit

Permalink
Merge pull request #94 from PierreBeucher/mac-support
Browse files Browse the repository at this point in the history
Mac and multi-arch support (x86_64, aarch64)
  • Loading branch information
PierreBeucher authored Feb 18, 2024
2 parents 9ad7f84 + 2e191eb commit 3289ba2
Show file tree
Hide file tree
Showing 12 changed files with 490 additions and 480 deletions.
134 changes: 23 additions & 111 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,11 @@ on:
branches:
- "**"
- "!main"
tags:
- "v*.*.*"

jobs:
test:

build-cross:
runs-on: ubuntu-latest
if: " ! startsWith(github.event.ref, 'refs/tags/v')"
steps:
- uses: actions/checkout@v3

Expand All @@ -32,18 +29,13 @@ jobs:
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-${{ runner.arch }}-cargo
target/
key: ${{ runner.os }}-${{ runner.arch }}-build-cross

- uses: actions/cache@v3
with:
path: |
~/.local/share/containers/storage/
key: ${{ runner.os }}-${{ runner.arch }}-podman
- run: nix develop .#cross -c make build-cross

- run: nix develop -c make test

build:
# Build and push to cachix
build-flake:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand All @@ -56,28 +48,10 @@ jobs:
with:
name: novops
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'

- uses: actions/cache@v3
with:
path: |
build/cache
key: ${{ runner.os }}-${{ runner.arch }}-podman

- run: nix develop -c make build-image build-binary

- name: Upload built artifacts
uses: actions/upload-artifact@v3
with:
name: novops-build
if-no-files-found: error
path: |
build/novops
build/novops.zip
build/novops.zip.sha256sum
build/image.tar
- run: nix build --json | jq -r '.[].outputs | to_entries[].value' | cachix push novops

# Build and push to cachix
build-flake:
test-cargo:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand All @@ -90,84 +64,22 @@ jobs:
with:
name: novops
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'

- run: nix build --json | jq -r '.[].outputs | to_entries[].value' | cachix push novops

# Some end-user CLI test
# Which cannot be tested easily with unit tests
test-novops-cli:
runs-on: ubuntu-latest
if: " ! startsWith(github.event.ref, 'refs/tags/v')"
needs: build
steps:
- uses: actions/checkout@v3

- name: download novops artifacts
uses: actions/download-artifact@v3
- uses: actions/cache@v3
with:
name: novops-build
path: build

- name: novops load
run: |
ls -al build
chmod +x build/novops
build/novops load -c tests/.novops.plain-strings.yml -s .envrc -e dev
cat .envrc >> "$GITHUB_ENV"
- name: check novops loaded values
run: env | grep MY_APP_HOST

- name: novops run and check var
run: |
build/novops run -c tests/.novops.plain-strings.yml -e dev -- sh -c "env | grep DOG_PATH"
- name: novops run with builtin env variables
run: |
export NOVOPS_CONFIG=tests/.novops.plain-strings.yml
export NOVOPS_ENVIRONMENT=dev
build/novops run -- sh -c "env | grep DOG_PATH"
- name: novops list environments
run: |
build/novops list environments -c tests/.novops.multi-env.yml | grep preprod
# json format should return "preprod" with quotes
build/novops list environments -c tests/.novops.multi-env.yml -o json | grep '"preprod"'
- name: novops list outputs
run: |
build/novops list outputs -e dev -c tests/.novops.multi-env.yml | grep MY_APP_HOST
build/novops list outputs -e dev -c tests/.novops.multi-env.yml -o json | grep '"MY_APP_HOST"'
# Upload artifacts for release tags only
release-artifacts:
needs: build
permissions:
contents: write
pull-requests: write
if: startsWith(github.event.ref, 'refs/tags/v')
runs-on: ubuntu-latest
steps:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-${{ runner.arch }}-cargo

- uses: actions/checkout@v3

- uses: cachix/install-nix-action@v20
with:
nix_path: nixpkgs=channel:nixos-unstable

- uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: download novops artifacts
uses: actions/download-artifact@v3
- uses: actions/cache@v3
with:
name: novops-build
path: build

- run: nix develop -c make docker-publish
path: |
~/.local/share/containers/storage/
key: ${{ runner.os }}-${{ runner.arch }}-podman

- run: nix develop -c make release-artifacts
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
# Plain cargo tests
- run: nix develop -c make test
4 changes: 0 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ jobs:
with:
name: novops
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'

- run: nix develop -c make release-tag
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}

- run: nix develop -c make release-pr
env:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/target/
.novops
build/
/release/

# Tests output
tests/output/
Expand Down
Loading

0 comments on commit 3289ba2

Please sign in to comment.