3636 id : set-matrix
3737 run : |
3838 # Get all module directories
39- ALL_MODULES=$(find modules -maxdepth 1 -mindepth 1 -type d | sort)
39+ ALL_MODULES=$(find modules -maxdepth 1 -mindepth 1 -type d | sed 's|^modules/||' | sort)
4040
4141 # Default to running all modules on main branch or if workflow_dispatch is used
4242 if [[ "${{ github.event_name }}" == "workflow_dispatch" || "${{ github.ref }}" == "refs/heads/main" ]]; then
5656 # Otherwise, determine which modules were modified
5757 MODIFIED_MODULES=""
5858 for MODULE in $ALL_MODULES; do
59- if echo "$MODIFIED_FILES" | grep -q "^$MODULE/"; then
59+ if echo "$MODIFIED_FILES" | grep -q "^modules/ $MODULE/"; then
6060 MODIFIED_MODULES="$MODIFIED_MODULES $MODULE"
6161 fi
6262 done
@@ -105,20 +105,23 @@ jobs:
105105 cache : true
106106
107107 - name : Get dependencies
108+ working-directory : modules/${{ matrix.module }}
108109 run : |
109110 go mod download
110111 go mod verify
111112
112113 - name : Run tests for ${{ matrix.module }}
114+ working-directory : modules/${{ matrix.module }}
113115 run : |
114- go test -v ./${{ matrix.module }}/ ... -coverprofile=${{ matrix.module }}-coverage.txt -covermode=atomic
116+ go test -v ./... -coverprofile=${{ matrix.module }}-coverage.txt -covermode=atomic
115117
116118 - name : Upload coverage for ${{ matrix.module }}
117119 uses : codecov/codecov-action@v5
118120 with :
119121 token : ${{ secrets.CODECOV_TOKEN }}
120122 slug : GoCodeAlone/modular
121- file : ./${{ matrix.module }}-coverage.txt
123+ directory : modules/${{ matrix.module }}/
124+ files : ${{ matrix.module }}-coverage.txt
122125 flags : ${{ matrix.module }}
123126
124127 # This job ensures each module can build properly
@@ -142,36 +145,43 @@ jobs:
142145 cache : true
143146
144147 - name : Get dependencies
148+ working-directory : modules/${{ matrix.module }}
145149 run : |
146150 go mod download
147151 go mod verify
148152
149153 - name : Verify ${{ matrix.module }}
154+ working-directory : modules/${{ matrix.module }}
150155 run : |
151156 # Verify package can be resolved
152- go list -e ./${{ matrix.module }}/ ...
157+ go list -e ./...
153158 # Run vet to check for issues
154- go vet ./${{ matrix.module }}/ ...
159+ go vet ./...
155160
156161 # Lint runs on all modules together for efficiency
157162 lint-modules :
158163 runs-on : ubuntu-latest
159164 needs : detect-modules
160- if : ${{ needs.detect-modules.outputs.modules != '[]' }}
165+ strategy :
166+ fail-fast : false
167+ matrix : ${{fromJson(needs.detect-modules.outputs.matrix)}}
168+
169+ name : Lint ${{ matrix.module }}
161170 steps :
162171 - uses : actions/checkout@v4
163172
164173 - uses : actions/setup-go@v5
165174 with :
166175 go-version : ${{ env.GO_VERSION }}
167- cache-dependency-path : go.sum
176+ cache-dependency-path : modules/${{ matrix.module }}/ go.sum
168177
169178 - name : golangci-lint
170179 uses : golangci/golangci-lint-action@v7
171180 with :
172181 version : latest
173182 only-new-issues : true
174- args : -c .golangci.github.yml --path-prefix=$(echo "${{ needs.detect-modules.outputs.modules }}" | jq -r '.[]' | paste -sd, -)
183+ working-directory : modules/${{ matrix.module }}
184+ args : -c ../../.golangci.github.yml
175185
176186 # This job summarizes the results
177187 modules-summary :
0 commit comments