Skip to content

Commit

Permalink
debug
Browse files Browse the repository at this point in the history
  • Loading branch information
itchyny committed Nov 23, 2023
1 parent ff0cdd2 commit 58d99dd
Show file tree
Hide file tree
Showing 3 changed files with 115 additions and 102 deletions.
127 changes: 111 additions & 16 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,124 @@ name: CI
on:
push:
branches:
- main
- main
- debug
tags:
- v*
pull_request:

permissions:
contents: read

defaults:
run:
shell: bash --noprofile --norc -euxo pipefail {0}

jobs:
test:
name: Test
runs-on: ${{ matrix.os }}
runs-on: ${{ matrix.runs-on }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: [ubuntu-latest, macos-latest, windows-latest]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Cache dependencies
uses: Swatinem/rust-cache@v2
- name: Build
run: cargo build
- name: Clippy
run: cargo clippy
- name: Test
run: cargo test
- name: Run
run: cargo run
- name: Uptime
run: node -e "console.log(require('os').uptime())"

build:
needs: test
runs-on: ${{ matrix.runs-on }}
strategy:
fail-fast: false
matrix:
os: [linux, darwin, windows]
arch: [amd64, arm64]
include:
- os: linux
arch: amd64
runs-on: ubuntu-latest
target: x86_64-unknown-linux-gnu
- os: linux
arch: arm64
runs-on: ubuntu-latest
target: aarch64-unknown-linux-gnu
- os: darwin
arch: amd64
runs-on: macos-latest
target: x86_64-apple-darwin
- os: darwin
arch: arm64
runs-on: macos-latest
target: aarch64-apple-darwin
- os: windows
arch: amd64
runs-on: windows-latest
target: x86_64-pc-windows-msvc
exclude:
- os: windows
arch: arm64
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set executable name
id: executable
run: echo name=${{ github.event.repository.name }} >> "$GITHUB_OUTPUT"
- name: Install target toolchain
if: matrix.arch == 'arm64'
run: |
rustup target add ${{ matrix.target }}
if [[ ${{ matrix.os }} == linux ]]; then
sudo apt-get install gcc-aarch64-linux-gnu
echo "RUSTFLAGS=-C linker=aarch64-linux-gnu-gcc" >> "$GITHUB_ENV"
fi
- name: Cache dependencies
uses: Swatinem/rust-cache@v2
- name: Build
run: cargo build --release --target=${{ matrix.target }}
- name: Run
if: matrix.arch == 'amd64'
run: target/${{ matrix.target }}/release/${{ steps.executable.outputs.name }}
- name: Set artifact name
id: artifact
run: echo name=${{ steps.executable.outputs.name }}_${{ github.ref_name }}_${{ matrix.os }}_${{ matrix.arch }} >> "$GITHUB_OUTPUT"
- name: Build artifact
run: |
mkdir ${{ steps.artifact.outputs.name }}
cp README.md LICENSE target/${{ matrix.target }}/release/${{ steps.executable.outputs.name }} ${{ steps.artifact.outputs.name }}
if [[ ${{ matrix.os }} == windows ]]; then
powershell Compress-Archive -Path ${{ steps.artifact.outputs.name }} -DestinationPath ${{ steps.artifact.outputs.name }}.zip
else
zip -r ${{ steps.artifact.outputs.name }}.zip ${{ steps.artifact.outputs.name }}
fi
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: ${{ steps.artifact.outputs.name }}
path: ${{ steps.artifact.outputs.name }}.zip

release:
needs: build
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Build
run: cargo build
- name: Install
run: cargo install --locked --path .
- name: Test
run: cargo test
- name: Run
run: cargo run
- name: Uptime
run: uptime
- name: Download artifacts
uses: actions/download-artifact@v3
- name: Create release
uses: ncipollo/release-action@v1
with:
name: Release ${{ github.ref_name }}
artifacts: '*/*.zip'
86 changes: 0 additions & 86 deletions .github/workflows/release.yaml

This file was deleted.

4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ license = "MIT"
keywords = ["cli", "mackerel"]
edition = "2021"

[profile.release]
strip = true
lto = true

[dependencies]
mackerel_plugin = "0.2.6"
uptime_lib = "0.3.0"
Expand Down

0 comments on commit 58d99dd

Please sign in to comment.