Skip to content

Commit c41aa60

Browse files
authored
Merge pull request #13 from Crown0815/feature/Enable-linux-docker-container-tests-with-windows-runner
Feature/use podman as OCI engine
2 parents 900c958 + 3f4ec69 commit c41aa60

1 file changed

Lines changed: 72 additions & 49 deletions

File tree

.github/workflows/build-release.yml

Lines changed: 72 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
- architecture: arm64
3838
os: windows-11-arm
3939
steps:
40-
- uses: actions/checkout@v4
40+
- uses: actions/checkout@v6
4141
with:
4242
github-server-url: https://code.forgejo.org
4343
repository: ${{ inputs.goal == 'test-fork' && vars.TEST_FORK || 'forgejo/runner' }}
@@ -60,7 +60,7 @@ jobs:
6060
exit 1
6161
}
6262
63-
- uses: actions/upload-artifact@v4
63+
- uses: actions/upload-artifact@v7
6464
with:
6565
name: forgejo-runner-windows-${{ matrix.architecture }}
6666
path: forgejo-runner-windows-${{ matrix.architecture }}.exe
@@ -74,72 +74,59 @@ jobs:
7474
FORGEJO_ADMIN_PASSWORD: 'admin_password'
7575
FORGEJO_RUNNER_SECRET: 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'
7676
MAX_WAIT_ITERATIONS: 30
77+
DOCKER_HOST: npipe:////./pipe/podman-machine-default
7778

7879
steps:
7980
- name: Windows - Checkout code
80-
uses: actions/checkout@v4
81+
uses: actions/checkout@v6
8182
with:
8283
github-server-url: https://code.forgejo.org
8384
repository: ${{ inputs.goal == 'test-fork' && vars.TEST_FORK || 'forgejo/runner' }}
8485
ref: ${{ inputs.tag }}
8586
token: ${{ secrets.CODE_FORGEJO_TOKEN }}
8687

87-
- name: Windows - Setup Windows Subsystem for Linux (WSL)
88-
uses: Vampire/setup-wsl@v6
89-
with:
90-
distribution: Alpine
91-
wsl-shell-user: root
92-
additional-packages: bash
93-
94-
- name: WSL - Install Docker
95-
shell: wsl-bash {0}
88+
- name: Install OCI-Container Runtime
9689
run: |
97-
apk --update add --no-cache docker curl
98-
99-
rc-update add docker default
100-
openrc default
101-
102-
# Wait for Docker to be ready
103-
i=0
104-
until docker info > /dev/null 2>&1 || (( i == ${{ env.MAX_WAIT_ITERATIONS }} )); do
105-
echo "Waiting for Docker to be ready... ($(( ++i ))/${{ env.MAX_WAIT_ITERATIONS }})"
106-
sleep 1
107-
done
108-
[ $i -lt ${{ env.MAX_WAIT_ITERATIONS }} ] && echo "Docker is ready!" || { echo "Timed out waiting for Docker" ; exit 1; }
90+
winget install --exact `
91+
--id RedHat.Podman `
92+
--version "5.7.1" `
93+
--source winget `
94+
--accept-package-agreements `
95+
--accept-source-agreements `
96+
--silent
97+
"C:\Program Files\RedHat\Podman" >> $env:GITHUB_PATH
98+
99+
- name: Create Linux-Container machine
100+
run: |
101+
podman machine init
102+
podman machine set --rootful
103+
podman machine start
109104
110105
- name: WSL - Start Forgejo Server
111-
shell: wsl-bash {0}
112106
run: |
113-
docker run -d --name forgejo \
114-
-p 3000:3000 \
115-
-e USER_UID=1000 \
116-
-e USER_GID=1000 \
117-
-e FORGEJO__security__INSTALL_LOCK=true \
118-
-e FORGEJO__server__DOMAIN=localhost \
119-
-e FORGEJO__server__ROOT_URL=${{ env.FORGEJO_ROOT_URL }} \
107+
docker run -d --name forgejo `
108+
-p 3000:3000 `
109+
-e USER_UID=1000 `
110+
-e USER_GID=1000 `
111+
-e FORGEJO__security__INSTALL_LOCK=true `
112+
-e FORGEJO__server__DOMAIN=localhost `
113+
-e FORGEJO__server__ROOT_URL=${{ env.FORGEJO_ROOT_URL }} `
120114
codeberg.org/forgejo/forgejo:11.0-rootless
121115
122116
- name: Windows - Set up Go
123-
uses: actions/setup-go@v5
117+
uses: actions/setup-go@v6
124118
with:
125119
go-version-file: go.mod
126120

127121
- name: Windows - Install dependencies
128-
run: go mod download
122+
run: |-
123+
go mod download
124+
go install gotest.tools/gotestsum@v1.13.0
129125
130126
- name: WSL - Register Runner on Forgejo Server
131127
# Starting the Forgejo server takes some time.
132128
# That time used to install go.
133-
shell: wsl-bash {0}
134129
run: |
135-
i=0
136-
until curl -s ${{ env.FORGEJO_ROOT_URL }}/api/v1/version > /dev/null || (( i == ${{ env.MAX_WAIT_ITERATIONS }} )); do
137-
echo "Waiting for Forgejo to be ready... ($(( ++i ))/${{ env.MAX_WAIT_ITERATIONS }})"
138-
sleep 1
139-
done
140-
[ $i -lt ${{ env.MAX_WAIT_ITERATIONS }} ] && echo "Forgejo is ready!" || { echo "Timed out waiting for Forgejo" ; exit 1; }
141-
142-
# Create admin user and generate runner token
143130
docker exec forgejo forgejo admin user create --admin --username ${{ env.FORGEJO_ADMIN_USER }} --password ${{ env.FORGEJO_ADMIN_PASSWORD }} --email root@example.com
144131
docker exec forgejo forgejo forgejo-cli actions register --labels docker --name therunner --secret ${{ env.FORGEJO_RUNNER_SECRET }}
145132
@@ -159,37 +146,73 @@ jobs:
159146
go run main.go create-runner-file --config temporaryConfig.yml --instance ${{ env.FORGEJO_ROOT_URL }} --secret ${{ env.FORGEJO_RUNNER_SECRET }} --name "windows-test-runner"
160147
161148
- name: Windows - Run tests
162-
run: go test -v ./internal/...
149+
run: gotestsum --jsonfile test-results.json --format pkgname -- -v ./internal/...
163150
env:
164151
FORGEJO_URL: ${{ env.FORGEJO_ROOT_URL }}
165152
FORGEJO_RUNNER_SECRET: ${{ env.FORGEJO_RUNNER_SECRET }}
166153
FORGEJO_RUNNER_HEX_SECRET: ${{ env.FORGEJO_RUNNER_SECRET }}
167154

155+
- name: Report test results
156+
uses: dorny/test-reporter@v2.6.0
157+
if: ${{ !cancelled() }}
158+
with:
159+
name: Runner Tests
160+
path: test-results.json
161+
reporter: golang-json
162+
168163
test-act:
169164
name: Run Act Tests on Windows
170165
runs-on: windows-latest
171166

172167
steps:
173168
- name: Windows - Checkout code
174-
uses: actions/checkout@v4
169+
uses: actions/checkout@v6
175170
with:
176171
github-server-url: https://code.forgejo.org
177172
repository: ${{ inputs.goal == 'test-fork' && vars.TEST_FORK || 'forgejo/runner' }}
178173
ref: ${{ inputs.tag }}
179174
token: ${{ secrets.CODE_FORGEJO_TOKEN }}
180175

176+
- name: Install OCI-Container Runtime
177+
run: |
178+
winget install --exact `
179+
--id RedHat.Podman `
180+
--version "5.7.1" `
181+
--source winget `
182+
--accept-package-agreements `
183+
--accept-source-agreements `
184+
--silent
185+
"C:\Program Files\RedHat\Podman" >> $env:GITHUB_PATH
186+
187+
- name: Create Linux-Container machine
188+
run: |
189+
podman machine init
190+
podman machine set --rootful
191+
podman machine start
192+
181193
- name: Windows - Set up Go
182-
uses: actions/setup-go@v5
194+
uses: actions/setup-go@v6
183195
with:
184196
go-version-file: go.mod
185197

186198
- name: Windows - Install dependencies
187-
run: go mod download
199+
run: |-
200+
go mod download
201+
go install gotest.tools/gotestsum@v1.13.0
188202
189203
- name: Windows - Run tests
190-
run: go test -v ./act/...
204+
run: gotestsum --jsonfile test-results.json --format pkgname -- -v ./act/...
191205
env:
192206
ACT_REPOSITORY: ${{ inputs.goal == 'test-fork' && vars.TEST_FORK || 'forgejo/runner' }} # Needed for TestRunContext_GetBindsAndMounts test case
207+
DOCKER_HOST: npipe:////./pipe/podman-machine-default
208+
209+
- name: Report test results
210+
uses: dorny/test-reporter@v2.6.0
211+
if: ${{ !cancelled() }}
212+
with:
213+
name: Act Tests
214+
path: test-results.json
215+
reporter: golang-json
193216

194217
release:
195218
runs-on: ubuntu-latest
@@ -198,7 +221,7 @@ jobs:
198221
permissions:
199222
contents: write
200223
steps:
201-
- uses: actions/download-artifact@v4
224+
- uses: actions/download-artifact@v8
202225
with:
203226
path: .
204227

0 commit comments

Comments
 (0)