refactor(x): migrate to golang.getoutline.org vanity URL
#2124
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build and Test | |
| on: | |
| push: | |
| branches: ["main"] | |
| pull_request: | |
| branches: ["main"] | |
| permissions: # added using https://github.com/step-security/secure-workflows | |
| contents: read | |
| jobs: | |
| test: | |
| strategy: | |
| matrix: | |
| os: [ubuntu-latest, macos-latest, windows-latest] | |
| runs-on: ${{ matrix.os }} | |
| env: | |
| OUTPUT_DIR: ${{ github.workspace }}/out | |
| steps: | |
| - name: Check out code into the Go module directory | |
| uses: actions/checkout@v3 | |
| - name: Set up Go | |
| uses: actions/setup-go@v4 | |
| with: | |
| go-version-file: "${{ github.workspace }}/go.mod" | |
| - name: Build SDK | |
| run: go build -v ./... | |
| - name: Build X | |
| run: go build -C x -tags psiphon -o "${{ env.OUTPUT_DIR }}/" -v ./... | |
| - name: Build Go Mobile | |
| if: matrix.os == 'macos-latest' || matrix.os == 'ubuntu-latest' | |
| run: go build -C x -o "${{ env.OUTPUT_DIR }}/" golang.org/x/mobile/cmd/gomobile golang.org/x/mobile/cmd/gobind | |
| - name: Build Mobileproxy (Android) | |
| if: matrix.os == 'ubuntu-latest' | |
| working-directory: ${{ github.workspace }}/x | |
| run: PATH="${{ env.OUTPUT_DIR }}:$PATH" gomobile bind -ldflags='-s -w' -v -tags=psiphon -target=android -androidapi=21 -o "${{ env.OUTPUT_DIR }}/mobileproxy.aar" github.com/Jigsaw-Code/outline-sdk/x/mobileproxy | |
| - name: Build Mobileproxy (iOS) | |
| if: matrix.os == 'macos-latest' | |
| working-directory: ${{ github.workspace }}/x | |
| run: PATH="${{ env.OUTPUT_DIR }}:$PATH" gomobile bind -ldflags='-s -w' -v -tags=psiphon -target=ios -iosversion=11.0 -o "${{ env.OUTPUT_DIR }}/mobileproxy.xcframework" github.com/Jigsaw-Code/outline-sdk/x/mobileproxy | |
| - name: Check SDK licenses | |
| # We allow only "notice" type of licenses. | |
| run: go tool go-licenses check --ignore=golang.org/x --allowed_licenses=Apache-2.0,Apache-3,BSD-3-Clause,BSD-4-Clause,CC0-1.0,MIT ./... | |
| - name: Check x licenses | |
| env: { GO_FLAGS: -C x } | |
| run: go tool go-licenses check --ignore=golang.org/x --allowed_licenses=Apache-2.0,Apache-3,BSD-3-Clause,BSD-4-Clause,CC0-1.0,MIT ./... | |
| - name: Test SDK | |
| # Enable nettests, which executes external network requests. | |
| run: go test -tags nettest -race -bench '.' ./... -benchtime=100ms | |
| - name: Test x | |
| # Enable nettests, which executes external network requests. | |
| run: go test -C x -tags nettest,psiphon -race -bench '.' ./... -benchtime=100ms | |
| android-test: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 10 | |
| strategy: | |
| matrix: | |
| api-level: [34] | |
| steps: | |
| - name: Check out code into the Go module directory | |
| uses: actions/checkout@v3 | |
| - name: Set up Go | |
| uses: actions/setup-go@v4 | |
| with: | |
| go-version-file: "${{ github.workspace }}/go.mod" | |
| - name: Set up Java | |
| uses: actions/setup-java@v3 | |
| with: | |
| distribution: "zulu" | |
| java-version: "17" | |
| # Free up disk space to avoid "Not enough space to create userdata partition" error. | |
| # See https://github.com/Jigsaw-Code/outline-sdk/actions/runs/20183073943/job/58094204027?pr=556#step:7:98 | |
| - name: Free up disk space | |
| run: | | |
| sudo rm -rf /usr/share/dotnet | |
| sudo rm -rf /opt/ghc | |
| sudo rm -rf /usr/local/share/boost | |
| # Android recipe from https://github.com/ReactiveCircus/android-emulator-runner/blob/v2/README.md#usage--examples | |
| # KVM makes the emulator faster. | |
| - name: Enable KVM | |
| run: | | |
| echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules | |
| sudo udevadm control --reload-rules | |
| sudo udevadm trigger --name-match=kvm | |
| - name: AVD cache | |
| uses: actions/cache@v4 | |
| id: avd-cache | |
| with: | |
| path: | | |
| ~/.android/avd | |
| ~/.android/adb* | |
| key: avd-${{ matrix.api-level }} | |
| - name: create AVD and generate snapshot for caching | |
| if: steps.avd-cache.outputs.cache-hit != 'true' | |
| uses: reactivecircus/android-emulator-runner@v2 | |
| with: | |
| arch: x86_64 | |
| target: aosp_atd | |
| api-level: ${{ matrix.api-level }} | |
| force-avd-creation: false | |
| emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none | |
| disable-animations: false | |
| script: | | |
| echo "Generated AVD snapshot for caching." | |
| ls ~/.android/avd | |
| ls ~/.android/ | |
| - name: Run Android unit tests | |
| uses: reactivecircus/android-emulator-runner@v2 | |
| with: | |
| arch: x86_64 | |
| # Using Automated Test Device because they are leaner. See | |
| # https://developer.android.com/studio/test/gradle-managed-devices#gmd-atd | |
| target: aosp_atd | |
| api-level: ${{ matrix.api-level }} | |
| force-avd-creation: false | |
| emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none | |
| script: | | |
| # We can't set environment variables in this script, nor refer to $ANDROID_NDK_HOME in the job.step.env block, so | |
| # we set it explicitly here. (#pain) | |
| CC="$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android${{ matrix.api-level }}-clang" GOOS=android GOARCH=amd64 CGO_ENABLED=1 go test -tags nettest -exec "${{ github.workspace }}/run_on_android.sh" -v ./... | |
| # TODO(fortuna): Fix psiphon and support testdata. | |
| CC="$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android${{ matrix.api-level }}-clang" GOOS=android GOARCH=amd64 CGO_ENABLED=1 go test -C x -tags nettest,psiphon -exec "${{ github.workspace }}/run_on_android.sh" -v ./... |