From ba8119131249861375d495b3b543099407e616aa Mon Sep 17 00:00:00 2001 From: alyssa Date: Tue, 14 Jan 2025 07:08:36 +0000 Subject: [PATCH] chore: clean up github actions workflows --- .github/workflows/dashboard.yml | 1 + .../{docker.yml => dotnet-docker.yml} | 1 + .../{dotnetformat.yml => dotnet.yml} | 17 +++++- .github/workflows/dotnetcore.yml | 41 ------------- .github/workflows/rust-docker.yml | 47 +++++++++++++++ .github/workflows/rust.yml | 57 +++++-------------- .github/workflows/rustfmt.yml | 16 ------ 7 files changed, 79 insertions(+), 101 deletions(-) rename .github/workflows/{docker.yml => dotnet-docker.yml} (97%) rename .github/workflows/{dotnetformat.yml => dotnet.yml} (59%) delete mode 100644 .github/workflows/dotnetcore.yml create mode 100644 .github/workflows/rust-docker.yml delete mode 100644 .github/workflows/rustfmt.yml diff --git a/.github/workflows/dashboard.yml b/.github/workflows/dashboard.yml index ae1b36e1..21beab30 100644 --- a/.github/workflows/dashboard.yml +++ b/.github/workflows/dashboard.yml @@ -8,6 +8,7 @@ on: jobs: build: + name: 'dashboard docker build' runs-on: ubuntu-latest permissions: packages: write diff --git a/.github/workflows/docker.yml b/.github/workflows/dotnet-docker.yml similarity index 97% rename from .github/workflows/docker.yml rename to .github/workflows/dotnet-docker.yml index cac201c6..af20524a 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/dotnet-docker.yml @@ -11,6 +11,7 @@ on: jobs: build: + name: '.net docker build' runs-on: ubuntu-latest permissions: packages: write diff --git a/.github/workflows/dotnetformat.yml b/.github/workflows/dotnet.yml similarity index 59% rename from .github/workflows/dotnetformat.yml rename to .github/workflows/dotnet.yml index a3dbf37d..5f6d0afe 100644 --- a/.github/workflows/dotnetformat.yml +++ b/.github/workflows/dotnet.yml @@ -1,20 +1,35 @@ -name: Format check on pull request +name: .net checks on: push: paths: + - .github/workflows/dotnet.yml - 'Myriad/**' - 'PluralKit.API/**' - 'PluralKit.Bot/**' - 'PluralKit.Core/**' pull_request: paths: + - .github/workflows/dotnet.yml - 'Myriad/**' - 'PluralKit.API/**' - 'PluralKit.Bot/**' - 'PluralKit.Core/**' jobs: + test: + name: 'run .net tests' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + with: + submodules: recursive + - name: Setup .NET Core + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 8.0.x + - name: Run automated tests + run: dotnet test --configuration Release dotnet-format: runs-on: ubuntu-latest steps: diff --git a/.github/workflows/dotnetcore.yml b/.github/workflows/dotnetcore.yml deleted file mode 100644 index 653cdbad..00000000 --- a/.github/workflows/dotnetcore.yml +++ /dev/null @@ -1,41 +0,0 @@ -name: .NET Core - -on: - push: - paths: - - 'Myriad/**' - - 'PluralKit.API/**' - - 'PluralKit.Bot/**' - - 'PluralKit.Core/**' - pull_request: - paths: - - 'Myriad/**' - - 'PluralKit.API/**' - - 'PluralKit.Bot/**' - - 'PluralKit.Core/**' - -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v1 - with: - submodules: recursive - - name: Setup .NET Core - uses: actions/setup-dotnet@v1 - with: - dotnet-version: 8.0.x - - name: Build with dotnet - run: dotnet build --configuration Release - test: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v1 - with: - submodules: recursive - - name: Setup .NET Core - uses: actions/setup-dotnet@v1 - with: - dotnet-version: 8.0.x - - name: Run automated tests - run: dotnet test --configuration Release diff --git a/.github/workflows/rust-docker.yml b/.github/workflows/rust-docker.yml new file mode 100644 index 00000000..293a2106 --- /dev/null +++ b/.github/workflows/rust-docker.yml @@ -0,0 +1,47 @@ +name: Build and push Rust service Docker images +on: + push: + paths: + - 'crates/**' + - '.github/workflows/rust.yml' + - 'ci/Dockerfile.rust' + - 'ci/rust-docker-target.sh' + - 'Cargo.toml' + - 'Cargo.lock' + +jobs: + build: + name: 'rust docker build' + runs-on: ubuntu-latest + permissions: + packages: write + if: github.repository == 'PluralKit/PluralKit' + steps: + - uses: docker/login-action@v1 + if: ${{ !env.ACT }} + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.CR_PAT }} + + - uses: actions/checkout@v2 + - uses: docker/setup-buildx-action@v1 + + # main docker build + - run: echo "BRANCH_NAME=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV + - uses: docker/build-push-action@v2 + with: + # https://github.com/docker/build-push-action/issues/378 + context: . + file: ci/Dockerfile.rust + push: false + cache-from: type=registry,ref=ghcr.io/pluralkit/docker-cache:rust + cache-to: type=registry,ref=ghcr.io/pluralkit/docker-cache:rust,mode=max + outputs: .docker-bin + + # add more binaries here + - run: | + tag=${{ github.sha }} \ + branch=${{ env.BRANCH_NAME }} \ + push=$([ "${{ github.repository }}" == "PluralKit/PluralKit" ] && echo true || echo false) \ + ci/rust-docker-target.sh diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 43972eee..7d88fe69 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -1,51 +1,22 @@ -# todo: use https://github.com/jpribyl/action-docker-layer-caching -# todo: make this generic for all Rust images in this repo -# todo: don't use docker/build-push-action -# todo: run builds on pull request - -name: Build and push Rust service Docker images +name: rust checks on: push: paths: - - 'crates/**' - - '.github/workflows/rust.yml' - - 'ci/Dockerfile.rust' - - 'ci/rust-docker-target.sh' - - 'Cargo.toml' - - 'Cargo.lock' + - .github/workflows/rust.yml + - 'crates/**' + pull_request: + paths: + - .github/workflows/rust.yml + - 'crates/**' jobs: - build: + rustfmt: + name: cargo fmt runs-on: ubuntu-latest - permissions: - packages: write - if: github.repository == 'PluralKit/PluralKit' steps: - - uses: docker/login-action@v1 - if: ${{ !env.ACT }} + - uses: actions/checkout@v4 + - uses: actions-rust-lang/setup-rust-toolchain@v1 with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.CR_PAT }} - - - uses: actions/checkout@v2 - - uses: docker/setup-buildx-action@v1 - - # main docker build - - run: echo "BRANCH_NAME=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV - - uses: docker/build-push-action@v2 - with: - # https://github.com/docker/build-push-action/issues/378 - context: . - file: ci/Dockerfile.rust - push: false - cache-from: type=registry,ref=ghcr.io/pluralkit/docker-cache:rust - cache-to: type=registry,ref=ghcr.io/pluralkit/docker-cache:rust,mode=max - outputs: .docker-bin - - # add more binaries here - - run: | - tag=${{ github.sha }} \ - branch=${{ env.BRANCH_NAME }} \ - push=$([ "${{ github.repository }}" == "PluralKit/PluralKit" ] && echo true || echo false) \ - ci/rust-docker-target.sh + components: rustfmt + - name: Rustfmt Check + uses: actions-rust-lang/rustfmt@v1 diff --git a/.github/workflows/rustfmt.yml b/.github/workflows/rustfmt.yml deleted file mode 100644 index 7be5f128..00000000 --- a/.github/workflows/rustfmt.yml +++ /dev/null @@ -1,16 +0,0 @@ -name: "Check Rust formatting" -on: - push: - pull_request: - -jobs: - rustfmt: - name: cargo fmt - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions-rust-lang/setup-rust-toolchain@v1 - with: - components: rustfmt - - name: Rustfmt Check - uses: actions-rust-lang/rustfmt@v1