|
| 1 | +name: Ruby checks |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + |
| 6 | +permissions: |
| 7 | + contents: read |
| 8 | + |
| 9 | +jobs: |
| 10 | + projects: |
| 11 | + name: Find ruby projects |
| 12 | + runs-on: ubuntu-latest |
| 13 | + steps: |
| 14 | + - name: Checkout source code |
| 15 | + uses: actions/checkout@v4 |
| 16 | + - name: Find all ruby projects |
| 17 | + id: projects |
| 18 | + uses: Rishabh510/Path-lister-action@master |
| 19 | + with: |
| 20 | + path: . |
| 21 | + type: .ruby-version |
| 22 | + - name: Output results |
| 23 | + run: | |
| 24 | + echo "Found ${{ steps.projects.outputs.path_count }} file(s) with this extension:" |
| 25 | + for i in ${{ steps.projects.outputs.paths }}; do |
| 26 | + echo $i |
| 27 | + done |
| 28 | + - name: Get the project paths |
| 29 | + id: paths |
| 30 | + run: | |
| 31 | + projects=() |
| 32 | + paths=(${{ steps.projects.outputs.paths }}) |
| 33 | + for i in "${paths[@]}"; do |
| 34 | + projects+=($(dirname "$i")) |
| 35 | + done |
| 36 | + output=$(echo "${projects[@]}" | jq --raw-input -c 'split(" ")') |
| 37 | + echo "OUTPUT: $output" |
| 38 | + echo "projects=${output}" >> $GITHUB_OUTPUT |
| 39 | + - name: Show all matching projects |
| 40 | + shell: bash |
| 41 | + run: | |
| 42 | + echo "${{ steps.paths.outputs.projects }}" |
| 43 | + outputs: |
| 44 | + projects: ${{ steps.paths.outputs.projects }} |
| 45 | + |
| 46 | + lint: |
| 47 | + name: Lint ruby code |
| 48 | + needs: projects |
| 49 | + runs-on: ubuntu-latest |
| 50 | + strategy: |
| 51 | + matrix: |
| 52 | + dir: ${{ fromJSON(needs.projects.outputs.projects) }} |
| 53 | + steps: |
| 54 | + - uses: actions/checkout@v4 |
| 55 | + - run: git fetch origin main --depth=1 |
| 56 | + - name: Set up Ruby |
| 57 | + uses: ruby/setup-ruby@v1 |
| 58 | + with: |
| 59 | + bundler-cache: true |
| 60 | + working-directory: ${{ matrix.dir }} |
| 61 | + - name: RuboCop Linter |
| 62 | + working-directory: ${{ matrix.dir }} |
| 63 | + run: bundle exec rubocop |
| 64 | + |
| 65 | + spec: |
| 66 | + name: Run ruby tests |
| 67 | + needs: projects |
| 68 | + runs-on: ubuntu-latest |
| 69 | + strategy: |
| 70 | + matrix: |
| 71 | + dir: ${{ fromJSON(needs.projects.outputs.projects) }} |
| 72 | + env: |
| 73 | + COVERAGE: 1 |
| 74 | + |
| 75 | + steps: |
| 76 | + - uses: actions/checkout@v4 |
| 77 | + - name: Set up Ruby |
| 78 | + uses: ruby/setup-ruby@v1 |
| 79 | + with: |
| 80 | + bundler-cache: true |
| 81 | + working-directory: ${{ matrix.dir }} |
| 82 | + - name: Run tests |
| 83 | + working-directory: ${{ matrix.dir }} |
| 84 | + run: bundle exec rspec |
0 commit comments