Skip to content

Commit

Permalink
Github actions tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
rsdy committed Jun 24, 2023
1 parent f5ff246 commit 415b27e
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 52 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/nix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,5 @@ jobs:
with:
name: symmetree-labs
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- run: nix build --json .#zerostash
- run: nix build --json .#zerostash-static
- run: nix build --json .#
- run: nix run '.#nixosTest'
105 changes: 59 additions & 46 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,15 @@ on:
types: [ published ]

env:
version: ${{ github.event.release.tag_name || github.head_ref }}
version: ${{ github.event.release.tag_name || github.sha }}
rust: 1.69.0 # same as nixos 23.05

jobs:
security_audit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions-rs/audit-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}

clippy_check:
runs-on: ubuntu-latest
steps:
- run: sudo apt-get -y install fuse3 libfuse3-dev
- uses: actions/checkout@v1
- uses: Swatinem/rust-cache@v2.4.0
- uses: actions-rs/toolchain@v1
with:
toolchain: nightly
components: clippy
override: true
- uses: actions-rs/clippy-check@v1
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9
- uses: actions-rs/audit-check@35b7b53b1e25b55642157ac01b4adceb5b9ebef3
with:
token: ${{ secrets.GITHUB_TOKEN }}

Expand All @@ -45,80 +31,107 @@ jobs:
]

include:
- name: linux
os: ubuntu-latest
asset_name: 0s-${{ github.event.release.tag_name || github.head_ref }}-linux-x86_64
target: x86_64-unknown-linux-musl
cross: true
tests: true
packages: -p zerostash -p zerostash-files

- name: macos
os: macos-latest
asset_name: 0s-${{ github.event.release.tag_name || github.head_ref }}-macos-x86_64
asset_name: 0s-${{ github.event.release.tag_name || github.sha }}-macos-x86_64
target: x86_64-apple-darwin
cross: false
tests: true
packages: -p zerostash -p zerostash-files

- name: macos-m1
os: macos-latest
asset_name: 0s-${{ github.event.release.tag_name || github.head_ref }}-macos-aarch64
asset_name: 0s-${{ github.event.release.tag_name || github.sha }}-macos-aarch64
target: aarch64-apple-darwin
cross: true
tests: false
packages: -p zerostash -p zerostash-files
skip_tests: true

- name: windows
os: windows-latest
asset_name: 0s-${{ github.event.release.tag_name || github.head_ref }}-windows-x86_64.exe
asset_name: 0s-${{ github.event.release.tag_name || github.sha }}-windows-x86_64.exe
target: x86_64-pc-windows-msvc
cross: false
tests: true
packages: -p zerostash -p zerostash-files

rust:
- 1.69.0 # MSRV

runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- uses: Swatinem/rust-cache@v2.4.0
- uses: actions-rs/toolchain@v1
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9
- uses: Swatinem/rust-cache@2656b87321093db1cb55fbd73183d195214fdfd1
- uses: actions-rs/toolchain@b2417cde72dcf67f306c0ae8e0828a81bf0b189f
with:
toolchain: stable
toolchain: ${{ env.rust }}
override: true
profile: minimal
components: clippy
target: ${{ matrix.target }}

- uses: actions-rs/clippy-check@b5b5f21f4797c02da247df37026fcd0a5024aa4d
if: matrix.skip_clippy != true
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --locked --target ${{ matrix.target }} ${{ matrix.packages }}

- name: Test
if: matrix.tests != false
uses: actions-rs/cargo@v1
if: matrix.skip_tests != true
uses: actions-rs/cargo@ae10961054e4aa8b4aa7dffede299aaf087aa33b
with:
use-cross: ${{ matrix.cross }}
args: --locked --target ${{ matrix.target }} --release ${{ matrix.packages }}
command: test

- name: Build
uses: actions-rs/cargo@v1
id: build
uses: actions-rs/cargo@ae10961054e4aa8b4aa7dffede299aaf087aa33b
with:
use-cross: ${{ matrix.cross }}
args: --locked --target ${{ matrix.target }} --release ${{ matrix.packages }}
command: build

- name: Upload binaries
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce
with:
name: ${{ matrix.asset_name }}
path: "target/${{ matrix.target }}/release/0s${{ matrix.os == 'windows-latest' && '.exe' || '' }}"

linux:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9
- uses: cachix/install-nix-action@4b933aa7ebcc94a6174cf1364864e957b4910265
- uses: cachix/cachix-action@6a9a34cdd93d0ae4b4b59fd678660efb08109f2f
with:
name: symmetree-labs
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'

- uses: actions-rs/toolchain@b2417cde72dcf67f306c0ae8e0828a81bf0b189f
with:
toolchain: ${{ env.rust }}
override: true
components: clippy

- run: sudo apt-get update && sudo apt-get install -y libfuse3-dev
- uses: actions-rs/clippy-check@b5b5f21f4797c02da247df37026fcd0a5024aa4d
with:
token: ${{ secrets.GITHUB_TOKEN }}

- id: build
run: |
path=$(echo $(nix build --json .#zerostash-static | jq .[].outputs.out))/bin/0s
echo bin-path=$path >> "$GITHUB_OUTPUT"
- name: Upload binaries
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce
with:
name: 0s-linux-${{ github.event.release.tag_name || github.sha }}-x86_64
path: ${{ steps.build.outputs.bin-path }}

release:
runs-on: ubuntu-latest
needs: [build, security_audit]
needs: [build, linux, security_audit]
if: github.event_name == 'release' && github.event.action == 'published'
steps:
- name: Download artifacts
uses: actions/download-artifact@v3
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a
with:
path: bin

Expand All @@ -135,7 +148,7 @@ jobs:
done
- name: Attach binaries to release
uses: actions/github-script@v6
uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410
with:
script: |
const fs = require('fs/promises');
Expand Down
10 changes: 6 additions & 4 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,12 @@

name = "zerostash";
pname = "0s";
src = pkgs.lib.sources.cleanSource (pkgs.lib.sources.cleanSourceWith {
src = ./.;
filter = name: type: !(pkgs.lib.hasPrefix ".github" (toString name));
});
src = pkgs.lib.sources.cleanSourceWith {
src = pkgs.lib.sources.cleanSource ./.;
filter = name: type:
let baseName = baseNameOf (toString name);
in !(".github" == baseName || ("nix" == baseName && type == "directory"));
};

cargoLock = { lockFile = ./Cargo.lock; };

Expand Down

0 comments on commit 415b27e

Please sign in to comment.