Skip to content

Commit a57382c

Browse files
authored
Merge pull request #64 from uyjulian/ci_improvements_20250918
CI improvements 20250918
2 parents 9869618 + 99d2492 commit a57382c

File tree

7 files changed

+201
-56
lines changed

7 files changed

+201
-56
lines changed

.github/workflows/compilation.yml

100644100755
Lines changed: 126 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,77 +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.os[0] }}
1325
strategy:
1426
matrix:
15-
os: [
16-
[macos-latest, arm64, bash],
17-
[macos-13, x86_64, bash],
18-
[ubuntu-latest, x86_64, bash],
19-
[windows-latest, x86_64, msys2]
20-
]
27+
os:
28+
- runs-on: macos-latest
29+
architecture: arm64
30+
shell: bash
31+
container: null
32+
container-options: " "
33+
macos-package-manager: brew
34+
- runs-on: macos-13
35+
architecture: x86_64
36+
shell: bash
37+
container: null
38+
container-options: " "
39+
macos-package-manager: brew
40+
- runs-on: macos-latest
41+
architecture: arm64
42+
shell: bash
43+
container: null
44+
container-options: " "
45+
macos-package-manager: port
46+
- runs-on: ubuntu-latest
47+
architecture: x86_64
48+
shell: bash
49+
container: "ubuntu:20.04"
50+
container-options: "--user 0"
51+
macos-package-manager: null
52+
- runs-on: ubuntu-24.04-arm
53+
architecture: arm64
54+
shell: bash
55+
container: "ubuntu:20.04"
56+
container-options: "--user 0"
57+
macos-package-manager: null
58+
- runs-on: windows-latest
59+
architecture: x86_64
60+
shell: msys2
61+
container: null
62+
container-options: " "
63+
macos-package-manager: null
2164
fail-fast: false
65+
runs-on: ${{ matrix.os.runs-on }}
2266
defaults:
2367
run:
24-
shell: ${{ matrix.os[2] }} {0}
68+
shell: ${{ matrix.os.shell }} {0}
69+
container:
70+
image: ${{ matrix.os.container }}
71+
options: ${{ matrix.os.container-options }}
72+
timeout-minutes: 240
2573

2674
steps:
27-
- uses: actions/checkout@v4
75+
- name: Checkout repository
76+
uses: actions/checkout@v4
2877

2978
- name: Install Ubuntu packages
30-
if: matrix.os[0] == 'ubuntu-latest'
79+
if: startsWith(matrix.os.runs-on, 'ubuntu')
3180
run: |
32-
sudo apt-get update
33-
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
3483
35-
- name: Install macOS packages
36-
if: startsWith(matrix.os[0], 'macos')
84+
- name: Install macOS packages (brew)
85+
if: startsWith(matrix.os.runs-on, 'macos') && matrix.os.macos-package-manager == 'brew'
3786
run: |
3887
brew update
39-
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
89+
90+
- name: Install macOS packages (port)
91+
if: startsWith(matrix.os.runs-on, 'macos') && matrix.os.macos-package-manager == 'port'
92+
run: |
93+
curl -LO https://raw.githubusercontent.com/GiovanniBussi/macports-ci/master/macports-ci
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
4096
4197
- name: Install MSYS2 packages
42-
if: matrix.os[0] == 'windows-latest'
98+
if: startsWith(matrix.os.runs-on, 'windows')
4399
uses: msys2/setup-msys2@v2
44100
with:
45101
msystem: MINGW32
46102
install: |
47-
base-devel git make texinfo flex bison patch mpc-devel tar
103+
base-devel git make texinfo flex bison patch binutils mpc-devel tar wget curl
104+
autotools gettext gettext-devel
48105
mingw-w64-i686-readline mingw-w64-i686-gcc mingw-w64-i686-cmake
49106
mingw-w64-i686-make mingw-w64-i686-libogg
50107
update: true
51108

52109
- name: Runs all the stages in the shell
110+
run: |
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
114+
115+
- name: Print version of executables (ps2toolchain-iop)
116+
if: github.event.repository.name == 'ps2toolchain-iop'
53117
run: |
54118
export PS2DEV=$PWD/ps2dev
55-
export PATH="$(brew --prefix gnu-sed)/libexec/gnubin:$PATH" # This is just needed for MacOS
56-
export PATH=$PATH:$PS2DEV/ee/bin
57-
./toolchain.sh
119+
export PATH=$PATH:$PS2DEV/iop/bin
120+
mipsel-none-elf-as --version
121+
mipsel-none-elf-ld --version
122+
mipsel-none-elf-gcc --version
58123
59-
- name: Print version of executables
124+
- name: Print version of executables (ps2toolchain-ee)
125+
if: github.event.repository.name == 'ps2toolchain-ee'
60126
run: |
61127
export PS2DEV=$PWD/ps2dev
62128
export PATH=$PATH:$PS2DEV/ee/bin
63129
mips64r5900el-ps2-elf-as --version
64130
mips64r5900el-ps2-elf-ld --version
65131
mips64r5900el-ps2-elf-gcc --version
66132
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+
67140
- name: Get short SHA
68141
id: slug
69-
run: 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
70143

71-
- name: Prepare ps2dev folder
144+
- name: Compress ps2dev folder
72145
run: |
73-
tar -zcvf ps2dev-${{matrix.os[0]}}.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 }}
74169

75-
- 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
76173
with:
77-
name: ps2dev-${{matrix.os[0]}}-ps2dev-${{matrix.os[1]}}-${{ steps.slug.outputs.sha8 }}
78-
path: ps2dev-${{matrix.os[0]}}.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 & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,38 +3,43 @@ 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: |
3041
echo "DOCKER_TAG=latest" >> $GITHUB_ENV
3142
32-
- name: Set up QEMU
33-
uses: docker/setup-qemu-action@v3
34-
35-
- name: Set up Docker Buildx
36-
uses: docker/setup-buildx-action@v3
37-
3843
- name: Login to DockerHub
3944
uses: docker/login-action@v3
4045
if: env.DOCKER_USERNAME != null
@@ -52,28 +57,61 @@ jobs:
5257
- name: Set docker tag list to include DockerHub if credentials available
5358
if: env.DOCKER_USERNAME != null
5459
run: |
55-
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
5661
5762
- name: Set docker tag list to not include DockerHub if credentials not available
5863
if: env.DOCKER_USERNAME == null
5964
run: |
60-
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
6166
6267
- name: Build and Push to container registry
6368
uses: docker/build-push-action@v5
6469
with:
6570
push: true
6671
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) }}
6794

95+
steps:
6896
- name: Send Compile action
6997
run: |
70-
export DISPATCH_ACTION="$(echo run_build)"
71-
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 }}"}'
72109

73-
- name: Repository Dispatch
110+
- name: Repository Dispatch to specific ${{ matrix.dest-repo }}
74111
uses: peter-evans/repository-dispatch@v3
75-
if: env.DISPATCH_TOKEN != null
112+
if: env.DISPATCH_TOKEN != null && contains(matrix.dest-repo, '/')
76113
with:
77-
repository: ${{ github.repository_owner }}/ps2toolchain
114+
repository: ${{ matrix.dest-repo }}
78115
token: ${{ secrets.DISPATCH_TOKEN }}
79116
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/ee/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: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,11 @@ OSVER=$(uname)
4141
if [ "$(uname -s)" = "Darwin" ]; then
4242
## Check if using brew
4343
if command -v brew &> /dev/null; then
44-
TARG_XTRA_OPTS="--with-system-zlib --with-gmp=$(brew --prefix gmp) --with-mpfr=$(brew --prefix mpfr)"
44+
TARG_XTRA_OPTS="--with-system-zlib --with-gmp=$(brew --prefix gmp) --with-mpfr=$(brew --prefix mpfr) --with-mpfr=$(brew --prefix mpfr)"
4545
elif command -v port &> /dev/null; then
46-
## Check if using MacPorts
47-
TARG_XTRA_OPTS="--with-system-zlib --with-gmp=$(port -q prefix gmp) --with-mpfr=$(port -q prefix mpfr)"
46+
MACPORT_BASE=$(dirname $(port -q contents gmp|grep gmp.h)|sed s#/include##g)
47+
printf 'Macport base is %s\n' "$MACPORT_BASE"
48+
TARG_XTRA_OPTS="--with-system-zlib --with-libiconv_prefix=$MACPORT_BASE --with-gmp=$MACPORT_BASE --with-mpfr=$MACPORT_BASE --with-mpc=$MACPORT_BASE"
4849
fi
4950
fi
5051

scripts/002-gcc-stage1.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ if [ "$(uname -s)" = "Darwin" ]; then
4545
TARG_XTRA_OPTS="--with-system-zlib --with-gmp=$(brew --prefix gmp) --with-mpfr=$(brew --prefix mpfr) --with-mpc=$(brew --prefix libmpc)"
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
50-
TARG_XTRA_OPTS="--with-system-zlib --with-gmp=$MACPORT_BASE --with-mpfr=$MACPORT_BASE --with-mpc=$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"
50+
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
5353

scripts/006-gcc-stage2.sh

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,16 @@ OSVER=$(uname)
4242
if [ "$(uname -s)" = "Darwin" ]; then
4343
## Check if using brew
4444
if command -v brew &> /dev/null; then
45-
export PATH="$(brew --prefix gnu-sed)/libexec/gnubin:$PATH"
4645
TARG_XTRA_OPTS="--with-system-zlib --with-gmp=$(brew --prefix gmp) --with-mpfr=$(brew --prefix mpfr) --with-mpc=$(brew --prefix libmpc)"
4746
elif command -v port &> /dev/null; then
4847
## 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
51-
alias sed='gsed'
52-
TARG_XTRA_OPTS="--with-system-zlib --with-gmp=$MACPORT_BASE --with-mpfr=$MACPORT_BASE --with-mpc=$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"
50+
TARG_XTRA_OPTS="--with-system-zlib --with-libiconv_prefix=$MACPORT_BASE --with-gmp=$MACPORT_BASE --with-mpfr=$MACPORT_BASE --with-mpc=$MACPORT_BASE"
5351
fi
52+
mkdir -p "build-sed-wrapper"
53+
ln -sf "$(which gsed)" "build-sed-wrapper/sed"
54+
export PATH="$(realpath build-sed-wrapper):$PATH"
5455
fi
5556
5657
## Determine the maximum number of processes that Make can work with.

0 commit comments

Comments
 (0)