|
91 | 91 | type: string |
92 | 92 | description: "Windows OS version label list (JSON)" |
93 | 93 | default: "[\"windows-2022\"]" |
| 94 | + freebsd_swift_versions: |
| 95 | + type: string |
| 96 | + description: "FreeBSD Swift version list (JSON)" |
| 97 | + default: "[\"nightly-main\"]" |
| 98 | + freebsd_exclude_swift_versions: |
| 99 | + type: string |
| 100 | + description: "Exclude FreeBSD Swift version list (JSON)" |
| 101 | + default: "[{\"swift_version\": \"\"}]" |
| 102 | + freebsd_os_versions: |
| 103 | + type: string |
| 104 | + description: "FreeBSD OS version list (JSON)" |
| 105 | + default: "[\"14.3\"]" |
| 106 | + freebsd_host_archs: |
| 107 | + type: string |
| 108 | + description: "FreeBSD host arch list (JSON)" |
| 109 | + default: "[\"x86_64\"]" |
94 | 110 | swift_flags: |
95 | 111 | type: string |
96 | 112 | description: "Swift flags for release version" |
|
178 | 194 | type: number |
179 | 195 | description: "The default step timeout in minutes" |
180 | 196 | default: 60 |
| 197 | + freebsd_pre_build_command: |
| 198 | + type: string |
| 199 | + description: "FreeBSD command to execute before building the Swift package" |
| 200 | + default: "" |
| 201 | + freebsd_build_command: |
| 202 | + type: string |
| 203 | + description: "FreeBSD command to build and test the package" |
| 204 | + default: "swift test" |
181 | 205 | macos_env_vars: |
182 | 206 | description: "Newline separated list of environment variables" |
183 | 207 | type: string |
|
190 | 214 | windows_env_vars: |
191 | 215 | description: "Newline separated list of environment variables" |
192 | 216 | type: string |
| 217 | + freebsd_env_vars: |
| 218 | + description: "Newline separated list of environment variables" |
| 219 | + type: string |
193 | 220 | enable_linux_checks: |
194 | 221 | type: boolean |
195 | 222 | description: "Boolean to enable linux testing. Defaults to true" |
|
230 | 257 | type: boolean |
231 | 258 | description: "Boolean to enable running build in windows docker container. Defaults to true" |
232 | 259 | default: true |
| 260 | + enable_freebsd_checks: |
| 261 | + type: boolean |
| 262 | + description: "Boolean to enable FreeBSD testing. Defaults to false" |
| 263 | + default: false |
233 | 264 | needs_token: |
234 | 265 | type: boolean |
235 | 266 | description: "Boolean to enable providing the GITHUB_TOKEN to downstream job." |
@@ -862,3 +893,101 @@ jobs: |
862 | 893 | timeout-minutes: ${{ inputs.windows_build_timeout }} |
863 | 894 | if: ${{ !inputs.enable_windows_docker }} |
864 | 895 | run: powershell.exe -NoLogo -File $env:TEMP\test-script\run.ps1; exit $LastExitCode |
| 896 | + |
| 897 | + freebsd-build: |
| 898 | + name: FreeBSD (${{ matrix.swift_version }} - ${{ matrix.os_version }} - ${{ matrix.arch }}) |
| 899 | + if: ${{ inputs.enable_freebsd_checks }} |
| 900 | + runs-on: ${{ matrix.runner }} |
| 901 | + strategy: |
| 902 | + fail-fast: false |
| 903 | + matrix: |
| 904 | + swift_version: ${{ fromJson(inputs.freebsd_swift_versions) }} |
| 905 | + os_version: ${{ fromJson(inputs.freebsd_os_versions) }} |
| 906 | + arch: ${{ fromJson(inputs.freebsd_host_archs) }} |
| 907 | + runner: ${{ |
| 908 | + fromJson( |
| 909 | + contains(fromJson(inputs.freebsd_host_archs), 'x86_64') && !contains(fromJson(inputs.freebsd_host_archs), 'aarch64') |
| 910 | + && '["ubuntu-24.04"]' |
| 911 | + || contains(fromJson(inputs.freebsd_host_archs), 'aarch64') && !contains(fromJson(inputs.freebsd_host_archs), 'x86_64') |
| 912 | + && '["ubuntu-24.04-arm"]' |
| 913 | + || '["ubuntu-24.04","ubuntu-24.04-arm"]' |
| 914 | + ) |
| 915 | + }} |
| 916 | + exclude: |
| 917 | + - ${{ fromJson(inputs.freebsd_exclude_swift_versions) }} |
| 918 | + - arch: x86_64 |
| 919 | + runner: ubuntu-24.04-arm |
| 920 | + - arch: aarch64 |
| 921 | + runner: ubuntu-24.04 |
| 922 | + steps: |
| 923 | + - name: Checkout repository |
| 924 | + uses: actions/checkout@v6 |
| 925 | + - name: Checkout swiftlang/github-workflows repository |
| 926 | + if: ${{ github.repository != 'swiftlang/github-workflows' }} |
| 927 | + uses: actions/checkout@v6 |
| 928 | + with: |
| 929 | + repository: swiftlang/github-workflows |
| 930 | + path: github-workflows |
| 931 | + - name: Validate host architecture |
| 932 | + env: |
| 933 | + ARCH: ${{ matrix.arch }} |
| 934 | + run: | |
| 935 | + if [[ "$ARCH" != "x86_64" ]]; then |
| 936 | + echo "::error::FreeBSD builds currently only support x86_64 host architecture" |
| 937 | + exit 1 |
| 938 | + fi |
| 939 | + - name: Determine Swift download URL |
| 940 | + id: swift_url |
| 941 | + env: |
| 942 | + SWIFT_VERSION: ${{ matrix.swift_version }} |
| 943 | + run: | |
| 944 | + if [[ "$SWIFT_VERSION" != "nightly-main" ]]; then |
| 945 | + echo "::error::FreeBSD builds currently only support nightly-main Swift version" |
| 946 | + exit 1 |
| 947 | + fi |
| 948 | + echo "url=https://download.swift.org/tmp-ci-nightly/development/freebsd-14_ci_latest.tar.gz" >> $GITHUB_OUTPUT |
| 949 | + - name: Provide token |
| 950 | + if: ${{ inputs.needs_token }} |
| 951 | + run: | |
| 952 | + echo "GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}" >> $GITHUB_ENV |
| 953 | + - name: Build / Test |
| 954 | + # zizmor: ignore[template-injection] |
| 955 | + uses: vmactions/freebsd-vm@v1 |
| 956 | + env: |
| 957 | + SWIFT_WEB_URL: ${{ steps.swift_url.outputs.url }} |
| 958 | + BUILD_FLAGS: ${{ (contains(matrix.swift_version, 'nightly') && inputs.swift_nightly_flags) || inputs.swift_flags }} |
| 959 | + FREEBSD_ENV_VARS: ${{ inputs.freebsd_env_vars }} |
| 960 | + with: |
| 961 | + envs: 'SWIFT_WEB_URL BUILD_FLAGS FREEBSD_ENV_VARS GITHUB_TOKEN' |
| 962 | + release: "${{ matrix.os_version }}" |
| 963 | + arch: "${{ matrix.arch }}" |
| 964 | + sync: rsync |
| 965 | + copyback: false |
| 966 | + usesh: true |
| 967 | + prepare: | |
| 968 | + fetch -o /tmp/swift.tar.gz "$SWIFT_WEB_URL" |
| 969 | + mkdir -p /opt/swift |
| 970 | + tar -xzf /tmp/swift.tar.gz -C /opt/swift |
| 971 | + pkg install -y git sqlite3 libuuid python3 curl brotli bash |
| 972 | + git config --global init.defaultBranch 'main' |
| 973 | + /opt/swift/usr/bin/swift --version |
| 974 | + run: | |
| 975 | + export PATH="/opt/swift/usr/bin:$PATH" |
| 976 | + swift --version |
| 977 | + if [ -n "$FREEBSD_ENV_VARS" ]; then |
| 978 | + printf '%s\n' "$FREEBSD_ENV_VARS" > /tmp/.env_vars |
| 979 | + while IFS= read -r _line || [ -n "$_line" ]; do |
| 980 | + export "$_line" |
| 981 | + done < /tmp/.env_vars |
| 982 | + fi |
| 983 | + if [ "${{ inputs.enable_cross_pr_testing && github.event_name == 'pull_request' }}" = "true" ]; then |
| 984 | + if [ "${{ github.repository }}" = "swiftlang/github-workflows" ]; then |
| 985 | + SCRIPT_ROOT="." |
| 986 | + else |
| 987 | + SCRIPT_ROOT="github-workflows" |
| 988 | + fi |
| 989 | + cat "$SCRIPT_ROOT/.github/workflows/scripts/cross-pr-checkout.swift" > /tmp/cross-pr-checkout.swift |
| 990 | + swift /tmp/cross-pr-checkout.swift "${{ github.repository }}" "${{ github.event.number }}" |
| 991 | + fi |
| 992 | + ${{ inputs.freebsd_pre_build_command }} |
| 993 | + ${{ inputs.freebsd_build_command }} $BUILD_FLAGS |
0 commit comments