Skip to content

Commit 1a6fa67

Browse files
authored
Merge pull request #39 from uyjulian/ci_improvements_20250918
CI improvements 20250918
2 parents 4b740b7 + a86ce25 commit 1a6fa67

File tree

6 files changed

+180
-62
lines changed

6 files changed

+180
-62
lines changed

.github/workflows/compilation.yml

100644100755
Lines changed: 114 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -2,108 +2,176 @@ name: CI
22

33
on:
44
push:
5+
paths-ignore:
6+
- '**.md'
7+
- '**.rst'
58
pull_request:
9+
paths-ignore:
10+
- '**.md'
11+
- '**.rst'
612
repository_dispatch:
713
types: [run_build, run_release]
814
workflow_dispatch: {}
15+
env:
16+
HOMEBREW_NO_ANALYTICS: 1
17+
HOMEBREW_NO_AUTO_UPDATE: 1
18+
HOMEBREW_NO_INSTALL_UPGRADE: 1
19+
HOMEBREW_NO_INSTALL_CLEANUP: 1
20+
DEBIAN_FRONTEND: noninteractive
21+
TZ: Japan
922

1023
jobs:
1124
build:
12-
runs-on: ${{ matrix.target.machine }}
1325
strategy:
1426
matrix:
15-
target:
16-
- machine: macos-latest
27+
os:
28+
- runs-on: macos-latest
1729
architecture: arm64
1830
shell: bash
19-
packageManager: brew
20-
- machine: macos-13
31+
container: null
32+
container-options: " "
33+
macos-package-manager: brew
34+
- runs-on: macos-13
2135
architecture: x86_64
2236
shell: bash
23-
packageManager: brew
24-
- machine: macos-latest
37+
container: null
38+
container-options: " "
39+
macos-package-manager: brew
40+
- runs-on: macos-latest
2541
architecture: arm64
2642
shell: bash
27-
packageManager: macport
28-
- machine: ubuntu-latest
43+
container: null
44+
container-options: " "
45+
macos-package-manager: port
46+
- runs-on: ubuntu-latest
2947
architecture: x86_64
3048
shell: bash
31-
packageManager: default
32-
- machine: ubuntu-22.04-arm
49+
container: "ubuntu:20.04"
50+
container-options: "--user 0"
51+
macos-package-manager: null
52+
- runs-on: ubuntu-24.04-arm
3353
architecture: arm64
3454
shell: bash
35-
packageManager: default
36-
- machine: ubuntu-24.04-arm
37-
architecture: arm64
38-
shell: bash
39-
packageManager: default
40-
- machine: windows-latest
55+
container: "ubuntu:20.04"
56+
container-options: "--user 0"
57+
macos-package-manager: null
58+
- runs-on: windows-latest
4159
architecture: x86_64
4260
shell: msys2
43-
packageManager: default
61+
container: null
62+
container-options: " "
63+
macos-package-manager: null
4464
fail-fast: false
65+
runs-on: ${{ matrix.os.runs-on }}
4566
defaults:
4667
run:
47-
shell: ${{ matrix.target.shell }} {0}
68+
shell: ${{ matrix.os.shell }} {0}
69+
container:
70+
image: ${{ matrix.os.container }}
71+
options: ${{ matrix.os.container-options }}
72+
timeout-minutes: 240
4873

4974
steps:
50-
- uses: actions/checkout@v4
75+
- name: Checkout repository
76+
uses: actions/checkout@v4
5177

5278
- name: Install Ubuntu packages
53-
if: startsWith(matrix.target.machine, 'ubuntu')
79+
if: startsWith(matrix.os.runs-on, 'ubuntu')
5480
run: |
55-
sudo apt-get update
56-
sudo apt-get -y install texinfo bison flex gettext libgmp3-dev libmpfr-dev libmpc-dev
81+
apt-get -y update
82+
apt-get -y -o Dpkg::Options::='--force-confdef' -o Dpkg::Options::='--force-confold' install texinfo bison flex gettext autopoint autoconf automake libgmp3-dev libmpfr-dev libmpc-dev cmake g++ gcc git libgsl-dev make patch zlib1g-dev wget curl
5783
58-
- name: Install macOS packages with brew
59-
if: startsWith(matrix.target.machine, 'macos') && matrix.target.packageManager == 'brew'
84+
- name: Install macOS packages (brew)
85+
if: startsWith(matrix.os.runs-on, 'macos') && matrix.os.macos-package-manager == 'brew'
6086
run: |
6187
brew update
62-
brew install texinfo bison flex gnu-sed gsl gmp mpfr libmpc
88+
brew install texinfo bison flex gnu-sed autoconf automake libtool gsl gmp mpfr libmpc md5sha1sum wget curl
6389
64-
- name: Install macOS packages with macport
65-
if: startsWith(matrix.target.machine, 'macos') && matrix.target.packageManager == 'macport'
90+
- name: Install macOS packages (port)
91+
if: startsWith(matrix.os.runs-on, 'macos') && matrix.os.macos-package-manager == 'port'
6692
run: |
6793
curl -LO https://raw.githubusercontent.com/GiovanniBussi/macports-ci/master/macports-ci
68-
source ./macports-ci install --remove-brew --version=2.11.5 --sync=rsync
69-
sudo port install gmp mpfr libmpc libiconv bison flex texinfo
94+
. ./macports-ci install --remove-brew --version=2.11.5 --sync=rsync
95+
sudo port install gsl gmp mpfr libmpc libiconv bison flex gsed texinfo autoconf automake libtool md5sha1sum wget curl
7096
7197
- name: Install MSYS2 packages
72-
if: startsWith(matrix.target.machine, 'windows')
98+
if: startsWith(matrix.os.runs-on, 'windows')
7399
uses: msys2/setup-msys2@v2
74100
with:
75101
msystem: MINGW32
76102
install: |
77-
base-devel git make texinfo flex bison patch binutils mpc-devel tar
78-
mingw-w64-i686-readline mingw-w64-i686-gcc
79-
mingw-w64-i686-cmake mingw-w64-i686-make mingw-w64-i686-libogg
103+
base-devel git make texinfo flex bison patch binutils mpc-devel tar wget curl
104+
autotools gettext gettext-devel
105+
mingw-w64-i686-readline mingw-w64-i686-gcc mingw-w64-i686-cmake
106+
mingw-w64-i686-make mingw-w64-i686-libogg
80107
update: true
81108

82109
- name: Runs all the stages in the shell
83110
run: |
84-
export PS2DEV=$PWD/ps2dev
85-
export PATH="$(brew --prefix gnu-sed)/libexec/gnubin:$PATH" # This is just needed for MacOS
86-
export PATH=$PATH:$PS2DEV/iop/bin
87-
./toolchain.sh
111+
. ./config/ci-env.sh
112+
if test -f ./build-all.sh; then ./build-all.sh; fi
113+
if test -f ./toolchain.sh; then ./toolchain.sh; fi
88114
89-
- name: Print version of executables
115+
- name: Print version of executables (ps2toolchain-iop)
116+
if: github.event.repository.name == 'ps2toolchain-iop'
90117
run: |
91118
export PS2DEV=$PWD/ps2dev
92119
export PATH=$PATH:$PS2DEV/iop/bin
93120
mipsel-none-elf-as --version
94121
mipsel-none-elf-ld --version
95122
mipsel-none-elf-gcc --version
96123
124+
- name: Print version of executables (ps2toolchain-ee)
125+
if: github.event.repository.name == 'ps2toolchain-ee'
126+
run: |
127+
export PS2DEV=$PWD/ps2dev
128+
export PATH=$PATH:$PS2DEV/ee/bin
129+
mips64r5900el-ps2-elf-as --version
130+
mips64r5900el-ps2-elf-ld --version
131+
mips64r5900el-ps2-elf-gcc --version
132+
133+
- name: Print version of executables (ps2toolchain-dvp)
134+
if: github.event.repository.name == 'ps2toolchain-dvp'
135+
run: |
136+
export PS2DEV=$PWD/ps2dev
137+
export PATH=$PATH:$PS2DEV/dvp/bin
138+
dvp-as --version
139+
97140
- name: Get short SHA
98141
id: slug
99-
run: |
100-
echo "sha8=${MSYSTEM}-sha[$(echo ${GITHUB_SHA} | cut -c1-8)]" >> $GITHUB_OUTPUT
142+
run: printf '%s\n' "sha8=$(printf '%s\n' ${GITHUB_SHA} | cut -c1-8)" >> $GITHUB_OUTPUT
101143

102-
- name: Prepare ps2dev folder
144+
- name: Compress ps2dev folder
103145
run: |
104-
tar -zcvf ps2dev-${{matrix.target.machine}}.tar.gz ps2dev
146+
tar -zcvf ps2dev-${{ matrix.os.runs-on }}.tar.gz ps2dev
147+
148+
- name: Upload artifact
149+
uses: actions/upload-artifact@v4
150+
with:
151+
name: ${{ github.event.repository.name }}-${{ matrix.os.runs-on }}-ps2dev-${{ matrix.os.architecture }}-${{ matrix.os.macos-package-manager }}-${{ steps.slug.outputs.sha8 }}
152+
path: ps2dev-${{ matrix.os.runs-on }}.tar.gz
153+
154+
- name: Extract tag name
155+
if: startsWith(github.ref, 'refs/tags/')
156+
id: tag
157+
run: printf 'VERSION=%s\n' "${GITHUB_REF/refs\/tags\//}" >> $GITHUB_OUTPUT
158+
159+
- name: Create pre-release
160+
if: (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main') && github.event.repository.name == 'ps2dev' && matrix.os.macos-package-manager != 'port'
161+
uses: softprops/action-gh-release@v2
162+
with:
163+
files: ps2dev-${{ matrix.os.runs-on }}.tar.gz
164+
prerelease: true
165+
name: "Development build"
166+
tag_name: latest
167+
env:
168+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
105169

106-
- uses: actions/upload-artifact@v4
170+
- name: Release
171+
if: startsWith(github.ref, 'refs/tags/') && github.event.repository.name == 'ps2dev' && matrix.os.macos-package-manager != 'port'
172+
uses: softprops/action-gh-release@v2
107173
with:
108-
name: ps2dev-${{matrix.target.machine}}-ps2dev-${{matrix.target.architecture}}-${{matrix.target.packageManager}}-${{ steps.slug.outputs.sha8 }}
109-
path: ps2dev-${{matrix.target.machine}}.tar.gz
174+
files: ps2dev-${{ matrix.os.runs-on }}.tar.gz
175+
tag_name: ${{ steps.tag.outputs.VERSION }}
176+
env:
177+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/docker.yml

100644100755
Lines changed: 56 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,38 @@ name: CI-Docker
33
on:
44
push:
55
branches:
6+
- master
67
- main
78
tags:
89
- v*
10+
paths-ignore:
11+
- '**.md'
12+
- '**.rst'
913
workflow_dispatch: {}
14+
repository_dispatch:
15+
types: [run_build]
1016

1117
jobs:
1218
build:
13-
runs-on: ubuntu-latest
1419
env:
1520
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
1621
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
17-
DISPATCH_TOKEN: ${{ secrets.DISPATCH_TOKEN }}
22+
BASE_DOCKER_IMAGE_NAME: ${{ (github.event.repository.name == 'ps2sdk' && 'ps2toolchain') || (github.event.repository.name == 'ps2sdk-ports' && 'ps2sdk') || (github.event.repository.name == 'ps2-packer' && 'ps2sdk') || (github.event.repository.name == 'ps2dev' && 'ps2sdk-ports') || 'none' }}
23+
strategy:
24+
matrix:
25+
runs-on: [ubuntu-latest, ubuntu-24.04-arm]
26+
runs-on: ${{ matrix.runs-on }}
27+
timeout-minutes: 180
1828

1929
steps:
20-
- uses: actions/checkout@v4
30+
- name: Checkout repository
31+
uses: actions/checkout@v4
2132

2233
- name: Extract DOCKER_TAG using tag name
2334
if: startsWith(github.ref, 'refs/tags/')
2435
run: |
25-
echo "DOCKER_TAG=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV
26-
36+
printf 'DOCKER_TAG=%s\n' "${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV
37+
2738
- name: Use default DOCKER_TAG
2839
if: startsWith(github.ref, 'refs/tags/') != true
2940
run: |
@@ -46,28 +57,61 @@ jobs:
4657
- name: Set docker tag list to include DockerHub if credentials available
4758
if: env.DOCKER_USERNAME != null
4859
run: |
49-
echo "DOCKER_TAG_LIST=ghcr.io/${{ github.repository }}:${{ env.DOCKER_TAG }},${{ github.repository }}:${{ env.DOCKER_TAG }}" >> $GITHUB_ENV
60+
printf 'DOCKER_TAG_LIST=%s\n' "ghcr.io/${{ github.repository }}:${{ env.DOCKER_TAG }},${{ github.repository }}:${{ env.DOCKER_TAG }}" >> $GITHUB_ENV
5061
5162
- name: Set docker tag list to not include DockerHub if credentials not available
5263
if: env.DOCKER_USERNAME == null
5364
run: |
54-
echo "DOCKER_TAG_LIST=ghcr.io/${{ github.repository }}:${{ env.DOCKER_TAG }}" >> $GITHUB_ENV
65+
printf 'DOCKER_TAG_LIST=%s\n' "ghcr.io/${{ github.repository }}:${{ env.DOCKER_TAG }}" >> $GITHUB_ENV
5566
5667
- name: Build and Push to container registry
5768
uses: docker/build-push-action@v5
5869
with:
5970
push: true
6071
tags: ${{ env.DOCKER_TAG_LIST }}
72+
build-args: |
73+
BASE_DOCKER_IMAGE=ghcr.io/${{ github.repository_owner }}/${{ env.BASE_DOCKER_IMAGE_NAME }}:${{ env.DOCKER_TAG }}
74+
BASE_DOCKER_DVP_IMAGE=ghcr.io/${{ github.repository_owner }}/ps2toolchain-dvp:${{ env.DOCKER_TAG }}
75+
BASE_DOCKER_IOP_IMAGE=ghcr.io/${{ github.repository_owner }}/ps2toolchain-iop:${{ env.DOCKER_TAG }}
76+
BASE_DOCKER_EE_IMAGE=ghcr.io/${{ github.repository_owner }}/ps2toolchain-ee:${{ env.DOCKER_TAG }}
77+
78+
- name: Gather information for repository dispatch
79+
id: dest-repo
80+
run: if test -f ./config/repository-dispatch.ini; then cat ./config/repository-dispatch.ini >> $GITHUB_OUTPUT; fi
81+
82+
perform-repository-dispatch:
83+
needs: [build]
84+
runs-on: ubuntu-latest
85+
container:
86+
image: ubuntu:20.04
87+
options: "--user 0"
88+
timeout-minutes: 20
89+
env:
90+
DISPATCH_TOKEN: ${{ secrets.DISPATCH_TOKEN }}
91+
strategy:
92+
matrix:
93+
dest-repo: ${{ fromJson(needs.build.outputs.DEST_REPO) }}
6194

95+
steps:
6296
- name: Send Compile action
6397
run: |
64-
export DISPATCH_ACTION="$(echo run_build)"
65-
echo "NEW_DISPATCH_ACTION=$DISPATCH_ACTION" >> $GITHUB_ENV
98+
export DISPATCH_ACTION="$(printf 'run_build\n')"
99+
printf 'NEW_DISPATCH_ACTION=%s\n' "$DISPATCH_ACTION" >> $GITHUB_ENV
100+
101+
- name: Repository Dispatch to ${{ matrix.dest-repo }}
102+
uses: peter-evans/repository-dispatch@v3
103+
if: env.DISPATCH_TOKEN != null && !contains(matrix.dest-repo, '/')
104+
with:
105+
repository: ${{ github.repository_owner }}/${{ matrix.dest-repo }}
106+
token: ${{ secrets.DISPATCH_TOKEN }}
107+
event-type: ${{ env.NEW_DISPATCH_ACTION }}
108+
client-payload: '{"ref": "${{ github.ref }}"}'
66109

67-
- name: Repository Dispatch
110+
- name: Repository Dispatch to specific ${{ matrix.dest-repo }}
68111
uses: peter-evans/repository-dispatch@v3
69-
if: env.DISPATCH_TOKEN != null
112+
if: env.DISPATCH_TOKEN != null && contains(matrix.dest-repo, '/')
70113
with:
71-
repository: ${{ github.repository_owner }}/ps2toolchain
114+
repository: ${{ matrix.dest-repo }}
72115
token: ${{ secrets.DISPATCH_TOKEN }}
73116
event-type: ${{ env.NEW_DISPATCH_ACTION }}
117+
client-payload: '{"ref": "${{ github.ref }}"}'

config/ci-env.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
3+
export PS2DEV=$PWD/ps2dev
4+
export PATH=$PATH:$PS2DEV/bin
5+
export PATH=$PATH:$PS2DEV/iop/bin

config/repository-dispatch.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
DEST_REPO=["ps2toolchain"]

scripts/001-binutils.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ if [ "$(uname -s)" = "Darwin" ]; then
4545
TARG_XTRA_OPTS="--with-system-zlib --with-gmp=$(brew --prefix gmp) --with-mpfr=$(brew --prefix mpfr)"
4646
elif command -v port &> /dev/null; then
4747
## Check if using MacPorts
48-
MACPORT_BASE=$(dirname `port -q contents gmp|grep gmp.h`|sed s#/include##g)
49-
echo Macport base is $MACPORT_BASE
48+
MACPORT_BASE=$(dirname $(port -q contents gmp|grep gmp.h)|sed s#/include##g)
49+
printf 'Macport base is %s\n' "$MACPORT_BASE"
5050
TARG_XTRA_OPTS="--with-system-zlib --with-libiconv_prefix=$MACPORT_BASE --with-gmp=$MACPORT_BASE --with-mpfr=$MACPORT_BASE --with-mpc=$MACPORT_BASE"
5151
fi
5252
fi

scripts/002-gcc-stage1.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ if [ "$(uname -s)" = "Darwin" ]; then
4646
TARG_XTRA_OPTS="--with-system-zlib --with-gmp=$(brew --prefix gmp) --with-mpfr=$(brew --prefix mpfr) --with-mpc=$(brew --prefix libmpc)"
4747
elif command -v port &> /dev/null; then
4848
## Check if using MacPorts
49-
MACPORT_BASE=$(dirname `port -q contents gmp|grep gmp.h`|sed s#/include##g)
50-
echo Macport base is $MACPORT_BASE
49+
MACPORT_BASE=$(dirname $(port -q contents gmp|grep gmp.h)|sed s#/include##g)
50+
printf 'Macport base is %s\n' "$MACPORT_BASE"
5151
TARG_XTRA_OPTS="--with-system-zlib --with-libiconv_prefix=$MACPORT_BASE --with-gmp=$MACPORT_BASE --with-mpfr=$MACPORT_BASE --with-mpc=$MACPORT_BASE"
5252
fi
5353
fi

0 commit comments

Comments
 (0)