Skip to content

Commit a846059

Browse files
committed
.github: Use devcontainer to run storage-operator unit-tests
1 parent 5b4e8fc commit a846059

File tree

2 files changed

+18
-20
lines changed

2 files changed

+18
-20
lines changed

.github/changed-files.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ unit-tests-metalk8s-operator:
3434

3535
unit-tests-storage-operator:
3636
- storage-operator/**
37+
- .devcontainer/**
3738

3839
unit-tests-salt:
3940
- salt/**

.github/workflows/pre-merge.yaml

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -276,32 +276,29 @@ jobs:
276276
run: make test
277277

278278
unit_tests_storage_operator:
279-
needs: changed-files
280-
if: needs.changed-files.outputs.unit-tests-storage-operator == 'true'
281-
runs-on: ubuntu-20.04
279+
runs-on: ubuntu-latest
280+
needs:
281+
- build-devcontainer
282+
- changed-files
283+
container:
284+
image: ghcr.io/${{ github.repository }}/devcontainer:${{ github.sha }}
285+
# We have to use `root` for the moment
286+
# Sees: https://github.com/actions/checkout/issues/1575
287+
# Could work with a user with 1001 id but not for docker
288+
options: --user root
289+
credentials:
290+
username: ${{ github.repository_owner }}
291+
password: ${{ secrets.GITHUB_TOKEN }}
282292
defaults:
283293
run:
294+
shell: bash
284295
working-directory: "storage-operator"
296+
if: needs.changed-files.outputs.unit-tests-storage-operator == 'true'
285297
steps:
286298
- name: Checkout
287299
uses: actions/checkout@v4
288-
- name: Install Go
289-
uses: actions/setup-go@v5
290-
with:
291-
go-version: "1.20.14"
292-
- name: Cache Go modules
293-
uses: actions/cache@v4
294-
env:
295-
cache-name: cache-go-modules
296-
with:
297-
path: |
298-
~/.cache/go-build
299-
~/go/pkg/mod
300-
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('go.sum') }}
301-
restore-keys: |
302-
${{ runner.os }}-build-${{ env.cache-name }}-
303-
${{ runner.os }}-build-
304-
${{ runner.os }}-
300+
- name: Set safe directory (since container is root and not user 1001)
301+
run: git config --global --add safe.directory $GITHUB_WORKSPACE
305302
- name: Run all storage-operator unit and integration tests
306303
run: make test
307304

0 commit comments

Comments
 (0)