Skip to content

Commit ef23df7

Browse files
committed
draft: new features
1 parent 4febb29 commit ef23df7

19 files changed

Lines changed: 674 additions & 261 deletions

File tree

.github/ps3netsrv-filter.jq

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ def add_version_to_tags(gitref):
1414
def add_commit_to_tags(gitref):
1515
.[] |= . + { "tags": (.tags + [(.commits | first)[:7] + (if gitref != "main" then "-edge" else "" end), (.commits | first) + (if gitref != "main" then "-edge" else "" end)]) };
1616

17+
# Add latest commit as ref
1718
def add_latest_commit_as_ref:
1819
.[] |= . + { "ref": (.commits | first) };
1920

.github/ps3netsrv-history.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
{
33
"version": "20240709",
44
"commits": [
5+
"7a36d7bf11aa8d7e6cb6e467980b70f08512dd03",
56
"485bf43291752656552c1d895b3263953f64cbcc"
67
]
78
},

.github/workflows/build-ps3netsrv-history.yml

Lines changed: 0 additions & 49 deletions
This file was deleted.

.github/workflows/docker-publish.yml

Lines changed: 104 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,98 @@
11
name: Docker build and publish
22

33
on:
4+
schedule:
5+
- cron: "0 1 * * *"
46
push:
57
paths-ignore:
68
- "*.md"
79
- "**/*.md"
8-
9-
# Publish `main` as Docker `edge` image.
1010
branches:
1111
- main
1212
- develop
13-
14-
# Run tests for any PRs.
1513
pull_request:
14+
workflow_dispatch:
1615

1716
env:
1817
IMAGE_NAME: ps3netsrv
1918
IMAGE_TITLE: ps3netsrv
2019
IMAGE_DESCRIPTION: Docker container for ps3netsrv
2120
IMAGE_LICENSE: gpl-3.0-or-later
21+
ALPINE_VERSION: 3.21
22+
DEBIAN_VERSION: bookworm-slim
23+
DEFAULT_BASE: alpine
2224

2325
jobs:
26+
update-ps3netsrv-history:
27+
runs-on: ubuntu-latest
28+
outputs:
29+
updated_history: ${{ steps.git-push.outputs.updated_history }}
30+
steps:
31+
- name: Determine branch to update
32+
id: update-branch
33+
run: |
34+
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
35+
echo "Updating branch: ${{ github.event.pull_request.head.ref }}"
36+
echo "branch=${{ github.event.pull_request.head.ref }}" >> $GITHUB_OUTPUT
37+
elif [[ "${{ github.event_name }}" == "schedule" ]]; then
38+
echo "Updating branch: ${{ github.event.repository.default_branch }}"
39+
echo "branch=${{ github.event.repository.default_branch }}" >> $GITHUB_OUTPUT
40+
elif [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
41+
echo "Updating branch: ${{ github.event.ref }}"
42+
echo "branch=${{ github.event.ref }}" >> $GITHUB_OUTPUT
43+
else
44+
echo "Unsupported event: ${{ github.event_name }}"
45+
exit 1
46+
fi
47+
48+
- uses: actions/checkout@v4
49+
with:
50+
token: ${{ secrets.REPO_SCOPED_TOKEN }}
51+
ref: ${{ steps.update-branch.outputs.branch }}
52+
53+
- uses: actions/checkout@v4
54+
with:
55+
token: ${{ secrets.REPO_SCOPED_TOKEN }}
56+
ref: master
57+
path: build/webman-mod
58+
repository: aldostools/webMAN-MOD
59+
fetch-depth: 0
60+
61+
- name: Fetch release version
62+
id: fetch-release
63+
run: |
64+
echo "Gathering ps3netsrv versions per commit..."
65+
git -C "$GITHUB_WORKSPACE/build/webman-mod" log --pretty=format:%H -- _Projects_/ps3netsrv ':(exclude,icase)_Projects_/ps3netsrv/bins/' ':(exclude,icase)_Projects_/ps3netsrv/*.md' ':(exclude,icase)_Projects_/ps3netsrv/*.txt' | \
66+
xargs -I {} bash -c '
67+
version=$(git -C "$GITHUB_WORKSPACE/build/webman-mod" show "{}:_Projects_/ps3netsrv/src/main.cpp" 2>/dev/null | sed -nr "s/.+ps3netsrv build ([0-9a-zA-Z]+).*/\1/p")
68+
[[ -z "$version" ]] && exit
69+
commit={}
70+
71+
echo "{ \"version\": \"$version\", \"commits\": \"$commit\"}"' | \
72+
jq -s | \
73+
tee /tmp/ps3netsrv_history_raw.json
74+
75+
echo "Merging ps3netsrv versions per commit..."
76+
jq '[reduce .[] as $d (null; .[$d.version] += [$d.commits]) | to_entries | sort_by(.key) | reverse | .[] | { version: .key, commits: .value}]' /tmp/ps3netsrv_history_raw.json | tee .github/ps3netsrv-history.json
77+
rm -rf "$GITHUB_WORKSPACE/build/webman-mod"
78+
79+
- name: Check for modified files
80+
id: git-check
81+
run: echo "modified=$([ -z "`git status --porcelain`" ] && echo "false" || echo "true")" >> $GITHUB_OUTPUT
82+
83+
- name: Commit latest release version
84+
if: steps.git-check.outputs.modified == 'true'
85+
id: git-push
86+
run: |
87+
git config user.name 'github-actions[bot]'
88+
git config user.email 'github-actions[bot]@users.noreply.github.com'
89+
git commit -am "chore(history): update ps3netsrv history"
90+
git push
91+
echo "updated_history=true" >> $GITHUB_OUTPUT
92+
2493
build-matrix:
94+
needs: update-ps3netsrv-history
95+
if: needs.update-ps3netsrv-history.outputs.updated_history != 'true'
2596
runs-on: ubuntu-latest
2697
outputs:
2798
releases: ${{ steps.set-matrix.outputs.releases }}
@@ -33,15 +104,16 @@ jobs:
33104
id: set-matrix
34105
run: |
35106
version_commit_map=$(jq -cr --arg gitref ${{ github.ref }} -f .github/ps3netsrv-filter.jq .github/ps3netsrv-history.json)
36-
echo "releases=${version_commit_map}" >> "$GITHUB_OUTPUT"
37107
echo "version_commit_map=${version_commit_map}"
108+
echo "releases=${version_commit_map}" >> "$GITHUB_OUTPUT"
38109
39110
# Run tests build
40111
test-build:
41112
needs: build-matrix
42113
strategy:
43114
matrix:
44115
release: ${{ fromJSON(needs.build-matrix.outputs.releases) }}
116+
baseimage: [alpine, slim]
45117
runs-on: ubuntu-latest
46118
steps:
47119
- name: Set up Docker Buildx
@@ -52,9 +124,9 @@ jobs:
52124
uses: actions/cache@v4
53125
with:
54126
path: /tmp/.test-buildx-cache
55-
key: ${{ runner.os }}-test-buildx-${{ matrix.release.version }}-${{ github.ref }}
127+
key: ${{ runner.os }}-test-buildx-${{ matrix.release.version }}-${{ matrix.baseimage }}-${{ github.ref }}
56128
restore-keys: |
57-
${{ runner.os }}-test-buildx-${{ matrix.release.version }}-${{ github.ref }}
129+
${{ runner.os }}-test-buildx-${{ matrix.release.version }}-${{ matrix.baseimage }}-${{ github.ref }}
58130
${{ runner.os }}-test-buildx-${{ github.ref }}
59131
60132
- name: Checkout
@@ -75,8 +147,13 @@ jobs:
75147
76148
echo "Would create tags:"
77149
for TAG in "${TAGS[@]}"; do
78-
DOCKERIO_TAGS="${DOCKERIO_TAGS},${DOCKERIO_IMAGE}:${TAG}"
79-
GHCRIO_TAGS="${GHCRIO_TAGS},${GHCRIO_IMAGE}:${TAG}"
150+
DOCKERIO_TAGS="${DOCKERIO_TAGS},${DOCKERIO_IMAGE}:${TAG}-${{ matrix.baseimage }}"
151+
GHCRIO_TAGS="${GHCRIO_TAGS},${GHCRIO_IMAGE}:${TAG}-${{ matrix.baseimage }}"
152+
# If default base we also tag the image without the base name
153+
if [[ ${{ matrix.baseimage }} == $DEFAULT_BASE ]]; then
154+
DOCKERIO_TAGS="${DOCKERIO_TAGS},${DOCKERIO_IMAGE}:${TAG}"
155+
GHCRIO_TAGS="${GHCRIO_TAGS},${GHCRIO_IMAGE}:${TAG}"
156+
fi
80157
done
81158
echo "DOCKERIO_TAGS=${DOCKERIO_TAGS:-}"
82159
echo "GHCRIO_TAGS=${GHCRIO_TAGS:-}"
@@ -85,15 +162,15 @@ jobs:
85162
uses: docker/build-push-action@v6
86163
with:
87164
builder: ${{ steps.buildx_test.outputs.name }}
88-
context: .
165+
file: ${{ matrix.baseimage }}.Dockerfile
89166
platforms: linux/amd64
90167
push: false
91168
load: true
92169
build-args: |
93170
BUILD_FROM_GIT=true
94171
PS3NETSRV_VERSION=${{ matrix.release.version }}
95172
PS3NETSRV_SRC_REF=${{ matrix.release.ref }}
96-
tags: ps3netsrv:test-build-${{ matrix.release.version }}
173+
tags: ps3netsrv:test-build-${{ matrix.release.version }}-${{ matrix.baseimage }}
97174
cache-from: type=local,src=/tmp/.test-buildx-cache
98175
cache-to: type=local,dest=/tmp/.test-buildx-cache-new
99176

@@ -107,8 +184,10 @@ jobs:
107184
108185
- name: Create ps3netsrv container...
109186
run: |
187+
echo "Changing permissions for tests/games..."
188+
sudo bash tests/setup-test-structure.sh
110189
echo "Starting ps3netsrv container..."
111-
docker run -t -d --name ps3netsrv-test ps3netsrv:test-build-${{ matrix.release.version }}
190+
docker run -t -d --name ps3netsrv-test -e PS3NETSRV_FIX_PERMISSIONS=true -v tests/games:/games ps3netsrv:test-build-${{ matrix.release.version }}-${{ matrix.baseimage }}
112191
echo "Trying 30 seconds to check for startup..."
113192
count=0
114193
exitcode=1
@@ -119,7 +198,7 @@ jobs:
119198
exitcode=0
120199
break
121200
else
122-
echo "Waiting for ps3netsrv to start..."
201+
echo "Waiting for ps3netsrv to start... $(docker logs ps3netsrv-test)"
123202
exitcode=1
124203
fi
125204
sleep 1
@@ -183,9 +262,15 @@ jobs:
183262
IFS=, read -r -a TAGS <<< "$PS3NETSRV_TAGS"
184263
185264
for TAG in "${TAGS[@]}"; do
186-
DOCKERIO_TAGS="${DOCKERIO_TAGS},${DOCKERIO_IMAGE}:${TAG}"
187-
GHCRIO_TAGS="${GHCRIO_TAGS},${GHCRIO_IMAGE}:${TAG}"
188-
README_TAGS="${README_TAGS}, \`${TAG}\`"
265+
DOCKERIO_TAGS="${DOCKERIO_TAGS},${DOCKERIO_IMAGE}:${TAG}-${{ matrix.baseimage }}"
266+
GHCRIO_TAGS="${GHCRIO_TAGS},${GHCRIO_IMAGE}:${TAG}-${{ matrix.baseimage }}"
267+
README_TAGS="${README_TAGS}, \`${TAG}-${{ matrix.baseimage }}\`"
268+
# If default base we also tag the image without the base name
269+
if [[ ${{ matrix.baseimage }} == $DEFAULT_BASE ]]; then
270+
DOCKERIO_TAGS="${DOCKERIO_TAGS},${DOCKERIO_IMAGE}:${TAG}"
271+
GHCRIO_TAGS="${GHCRIO_TAGS},${GHCRIO_IMAGE}:${TAG}"
272+
README_TAGS="${README_TAGS}, \`${TAG}\`"
273+
fi
189274
done
190275
191276
echo "version=${PS3NETSRV_VERSION}" >> $GITHUB_OUTPUT
@@ -208,7 +293,7 @@ jobs:
208293
uses: docker/build-push-action@v6
209294
with:
210295
builder: ${{ steps.buildx.outputs.name }}
211-
context: .
296+
file: ${{ matrix.baseimage }}.Dockerfile
212297
platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6
213298
push: ${{ steps.prep.outputs.publish == 'true' }}
214299
tags: ${{ steps.prep.outputs.tags }}
@@ -257,7 +342,7 @@ jobs:
257342
uses: actions/checkout@v4
258343
with:
259344
ref: main
260-
345+
261346
- name: Set start and end comment
262347
if: needs.build.outputs.publish == 'true'
263348
id: comment
@@ -288,7 +373,7 @@ jobs:
288373
- name: Check for modified files
289374
if: needs.build.outputs.publish == 'true'
290375
id: git-check
291-
run: echo modified=$([ -z "`git status --porcelain`" ] && echo "false" || echo "true") >> $GITHUB_OUTPUT
376+
run: echo "modified=$([ -z "`git status --porcelain`" ] && echo "false" || echo "true")" >> $GITHUB_OUTPUT
292377

293378
- name: Commit updated README.md
294379
if: steps.git-check.outputs.modified == 'true'

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
games/
2+
build/

0 commit comments

Comments
 (0)