Skip to content

Commit

Permalink
ci: better
Browse files Browse the repository at this point in the history
  • Loading branch information
Alxandr committed Oct 8, 2024
1 parent 6328a5f commit 1737e0d
Show file tree
Hide file tree
Showing 7 changed files with 113 additions and 46 deletions.
11 changes: 11 additions & 0 deletions .github/scripts/list-verticals.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { verticals } from "./_meta.mts";
import * as actions from "@actions/core";

const type = process.argv[2];

let output = verticals;
if (type) {
output = verticals.filter((v) => v.type === type);
}

actions.setOutput("verticals", JSON.stringify(output.map((v) => v.name)));
1 change: 1 addition & 0 deletions .github/scripts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"author": "",
"private": true,
"devDependencies": {
"@actions/core": "^1.11.1",
"@octokit/action": "^7.0.0",
"@types/node": "^20.11.30",
"chalk": "^5.3.0",
Expand Down
51 changes: 51 additions & 0 deletions .github/scripts/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 36 additions & 0 deletions .github/workflows/_find-verticals.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: "Template: Find verticals"

on:
workflow_call:
outputs:
verticals:
value: ${{ jobs.list.outputs.verticals }}
description: JSON list of folders in either <apps, pkgs, libs>

inputs:
type:
required: true
description: <app, pkg, lib>
type: string

jobs:
list:
name: Find ${{ inputs.type }}s
runs-on: ubuntu-latest

outputs:
verticals: ${{ steps.list.outputs.verticals }}

steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v3
with:
version: 9
run_install: |
- cwd: .github/scripts
args: [--frozen-lockfile]
- args: [--global, tsx]
- name: Update all sln files
id: list
run: tsx ./.github/scripts/list-verticals.mts ${{ inputs.type }}
16 changes: 7 additions & 9 deletions .github/workflows/apps-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,20 @@ on:

env:
DOTNET_VERSION: 8.0.x
DIR: src/apps

jobs:
bundle:
name: Bundle Apps
uses: ./.github/workflows/bundle-template.yml
find-verticals:
uses: ./.github/workflows/_find-verticals.yml
with:
dir: apps
type: app

ci:
name: CI
runs-on: ubuntu-latest
needs: bundle
needs: find-verticals
strategy:
matrix:
name: ${{ fromJson(needs.bundle.outputs.dirs) }}
path: ${{ fromJson(needs.find-verticals.outputs.verticals) }}

steps:
- uses: actions/checkout@v4
Expand All @@ -36,10 +34,10 @@ jobs:
dotnet-version: ${{ env.DOTNET_VERSION }}

- name: Build
working-directory: ${{ env.DIR }}/${{ matrix.name }}
working-directory: ${{ matrix.path }}
run: dotnet build

- name: Test
if: always()
working-directory: src/apps/${{ matrix.name }}
working-directory: ${{ matrix.path }}
run: dotnet test --no-build
29 changes: 0 additions & 29 deletions .github/workflows/bundle-template.yml

This file was deleted.

15 changes: 7 additions & 8 deletions .github/workflows/libs-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,18 @@ env:
DIR: src/libs

jobs:
bundle:
name: Bundle Libs
uses: ./.github/workflows/bundle-template.yml
find-verticals:
uses: ./.github/workflows/_find-verticals.yml
with:
dir: libs
type: app

ci:
name: CI
runs-on: ubuntu-latest
needs: bundle
needs: find-verticals
strategy:
matrix:
name: ${{ fromJson(needs.bundle.outputs.dirs) }}
path: ${{ fromJson(needs.find-verticals.outputs.verticals) }}

steps:
- uses: actions/checkout@v4
Expand All @@ -36,10 +35,10 @@ jobs:
dotnet-version: ${{ env.DOTNET_VERSION }}

- name: Build
working-directory: ${{ env.DIR }}/${{ matrix.name }}
working-directory: ${{ matrix.path }}
run: dotnet build

- name: Test
if: always()
working-directory: ${{ env.DIR }}/${{ matrix.name }}
working-directory: ${{ matrix.path }}
run: dotnet test --no-build

0 comments on commit 1737e0d

Please sign in to comment.