From 009df3c1ef019b9fb44b56fcaa2942f5faf52637 Mon Sep 17 00:00:00 2001 From: tison Date: Sat, 23 Mar 2024 22:08:25 +0800 Subject: [PATCH] ci: add sanity check and action.yml Signed-off-by: tison --- .github/workflows/ci.yml | 33 +++++++++++++++++++++++++++++++++ .gitignore | 1 + action.yml | 40 ++++++++++++++++++++++++++++++++++++++++ licenserc.toml | 4 ++++ 4 files changed, 78 insertions(+) create mode 100644 action.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 05a1140..30414af 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -57,12 +57,44 @@ jobs: - name: Run benches run: cargo bench --workspace -- --test + docker: + if: (github.event_name != 'schedule') || (github.repository == 'korandoru/hawkeye') + strategy: + fail-fast: false + matrix: + os: [ ubuntu-latest, buildjet-4vcpu-ubuntu-2204-arm ] + runs-on: ${{matrix.os}} + name: Build and test ${{matrix.name}} ${{matrix.os}} + steps: + - uses: actions/checkout@v4 + - name: Build and load + uses: docker/build-push-action@v3 + with: + context: . + file: Dockerfile + tags: hawkeye:ci + outputs: type=docker + - name: Save image + run: docker save hawkeye:ci -o /tmp/hawkeye-${{matrix.os}}.tar + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: hawkeye-${{matrix.os}} + path: /tmp/hawkeye-${{matrix.os}}.tar + - name: Sanity check + run: | + cp action.yml action.yml.bak + docker image inspect hawkeye:ci --format='{{.Size}}' + docker run --rm -v $(pwd):/github/workspace hawkeye:ci -V + docker run --rm -v $(pwd):/github/workspace hawkeye:ci check + required: name: Required runs-on: ubuntu-latest if: ${{ always() }} needs: - check + - docker - test steps: - name: Guardian @@ -70,6 +102,7 @@ jobs: if [[ ! ( \ "${{ needs.check.result }}" == "success" \ && "${{ needs.test.result }}" == "success" \ + && "${{ needs.docker.result }}" == "success" \ ) ]]; then echo "Required jobs haven't been completed successfully." exit -1 diff --git a/.gitignore b/.gitignore index ea8c4bf..5e5e33f 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /target +*.bak diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..223f844 --- /dev/null +++ b/action.yml @@ -0,0 +1,40 @@ +# Copyright 2024 tison +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +name: HawkEye Action +description: 'Check, format, or remove license headers.' +author: 'tison ' +branding: + icon: 'code' + color: 'blue' + +inputs: + config: + description: The configuration file + required: false + default: licenserc.toml + mode: + description: | + Which mode License Eye should be run in. Choices are `check` or `fix`. The + default value is `check`. + required: false + default: check + +runs: + using: docker + image: docker://ghcr.io/korandoru/hawkeye-native:latest + args: + - ${{ inputs.mode }} + - --config + - ${{ inputs.config }} diff --git a/licenserc.toml b/licenserc.toml index cc3c0b2..7969989 100644 --- a/licenserc.toml +++ b/licenserc.toml @@ -14,6 +14,10 @@ headerPath = "Apache-2.0.txt" +excludes = [ + "*.txt", +] + [properties] inceptionYear = 2024 copyrightOwner = "tison "