name: Tests and Checkings on: push: pull_request: types: [opened, synchronize, reopened] jobs: check-assets: runs-on: ubuntu-latest if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name steps: - name: Restore Geodat Cache uses: actions/cache/restore@v6 with: path: resources key: xray-geodat- - name: Check Assets Existence id: check-assets run: | [ -d 'resources' ] || mkdir resources LIST=('geoip.dat' 'geosite.dat') for FILE_NAME in "${LIST[@]}" do echo -e "Checking ${FILE_NAME}..." if [ -s "./resources/${FILE_NAME}" ]; then echo -e "${FILE_NAME} exists." else echo -e "${FILE_NAME} does not exist." echo "missing=true" >> $GITHUB_OUTPUT break fi done - name: Sleep for 90 seconds if Assets Missing if: steps.check-assets.outputs.missing == 'true' run: sleep 90 check-proto: runs-on: ubuntu-latest if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name steps: - name: Checkout codebase uses: actions/checkout@v7 - name: Set up Go uses: actions/setup-go@v7 with: go-version-file: go.mod - name: Install pinned protobuf tools working-directory: ${{ runner.temp }} env: GOBIN: ${{ runner.temp }}/protobuf/bin run: | curl -fsSL --retry 3 -o protoc.zip https://github.com/protocolbuffers/protobuf/releases/download/v33.5/protoc-33.5-linux-x86_64.zip unzip -q protoc.zip -d protobuf go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.36.11 go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.6.0 echo "GOBIN=$GOBIN" >> "$GITHUB_ENV" echo "$GOBIN" >> "$GITHUB_PATH" - name: Check generated protobuf files run: | # Remove old outputs so orphaned pb files are also detected. git ls-files -z -- '*.pb.go' | xargs -0 -r rm -- go run ./infra/vprotogen # Include newly generated files in the diff without committing. git add --intent-to-add --force -- '*.pb.go' git diff --exit-code HEAD -- '*.pb.go' check-format: runs-on: ubuntu-latest if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name permissions: contents: read steps: - name: Checkout codebase uses: actions/checkout@v7 - name: Set up Go uses: actions/setup-go@v7 with: go-version-file: go.mod check-latest: true cache: false - name: Check Format run: go run ./infra/vformat/main.go -mode check -pwd ./ test: needs: check-assets if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name permissions: contents: read runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: os: [windows-latest, ubuntu-latest, macos-latest] steps: - name: Checkout codebase uses: actions/checkout@v7 - name: Set up Go uses: actions/setup-go@v7 with: go-version-file: go.mod check-latest: true - name: Restore Geodat Cache uses: actions/cache/restore@v6 with: path: resources key: xray-geodat- enableCrossOsArchive: true - name: Test run: go test -timeout 1h -v ./...