|
| 1 | +on: |
| 2 | + pull_request: |
| 3 | + workflow_dispatch: |
| 4 | + |
| 5 | +name: Go Git Integration |
| 6 | +permissions: |
| 7 | + contents: read |
| 8 | + |
| 9 | +jobs: |
| 10 | + test: |
| 11 | + name: ${{ matrix.os }} / Go stable |
| 12 | + runs-on: ${{ matrix.os }} |
| 13 | + strategy: |
| 14 | + fail-fast: false |
| 15 | + matrix: |
| 16 | + os: |
| 17 | + - ubuntu-latest |
| 18 | + - macos-latest |
| 19 | + - windows-latest |
| 20 | + defaults: |
| 21 | + run: |
| 22 | + shell: bash |
| 23 | + steps: |
| 24 | + - name: Checkout go-billy |
| 25 | + uses: actions/checkout@v4 |
| 26 | + with: |
| 27 | + path: go-billy |
| 28 | + |
| 29 | + - name: Select go-git branch |
| 30 | + id: target |
| 31 | + run: | |
| 32 | + set -e |
| 33 | + module_path="$(awk '$1 == "module" { print $2 }' go-billy/go.mod)" |
| 34 | +
|
| 35 | + case "${module_path}" in |
| 36 | + github.com/go-git/go-billy/v6) |
| 37 | + go_git_ref="main" |
| 38 | + ;; |
| 39 | + github.com/go-git/go-billy/v5) |
| 40 | + go_git_ref="releases/v5.x" |
| 41 | + ;; |
| 42 | + *) |
| 43 | + echo "::error::unsupported go-billy module path: ${module_path}" |
| 44 | + exit 1 |
| 45 | + ;; |
| 46 | + esac |
| 47 | +
|
| 48 | + echo "go_billy_module=${module_path}" >> "${GITHUB_OUTPUT}" |
| 49 | + echo "go_git_ref=${go_git_ref}" >> "${GITHUB_OUTPUT}" |
| 50 | + echo "Testing ${module_path} against go-git ${go_git_ref}" |
| 51 | +
|
| 52 | + - name: Checkout go-git |
| 53 | + uses: actions/checkout@v4 |
| 54 | + with: |
| 55 | + repository: go-git/go-git |
| 56 | + ref: ${{ steps.target.outputs.go_git_ref }} |
| 57 | + path: go-git |
| 58 | + fetch-depth: 0 |
| 59 | + |
| 60 | + - name: Install Go |
| 61 | + uses: actions/setup-go@v5 |
| 62 | + with: |
| 63 | + go-version: stable |
| 64 | + cache-dependency-path: | |
| 65 | + go-billy/go.sum |
| 66 | + go-git/**/go.sum |
| 67 | +
|
| 68 | + - name: Use local go-billy |
| 69 | + run: | |
| 70 | + set -e |
| 71 | + go_billy_dir="$(cd go-billy && pwd)" |
| 72 | + go_git_dir="$(cd go-git && pwd)" |
| 73 | + go_billy_module="${{ steps.target.outputs.go_billy_module }}" |
| 74 | +
|
| 75 | + if command -v cygpath >/dev/null 2>&1; then |
| 76 | + go_billy="$(cygpath -m "${go_billy_dir}")" |
| 77 | + go_git="$(cygpath -m "${go_git_dir}")" |
| 78 | + else |
| 79 | + go_billy="${go_billy_dir}" |
| 80 | + go_git="${go_git_dir}" |
| 81 | + fi |
| 82 | +
|
| 83 | + cd go-git |
| 84 | + go_git_module="$(awk '$1 == "module" { print $2 }' go.mod)" |
| 85 | + go mod edit -replace "${go_billy_module}=${go_billy}" |
| 86 | + go mod tidy |
| 87 | +
|
| 88 | + if [ -f cli/go-git/go.mod ]; then |
| 89 | + cd cli/go-git |
| 90 | + go mod edit -replace "${go_git_module}=${go_git}" |
| 91 | + go mod edit -replace "${go_billy_module}=${go_billy}" |
| 92 | + go mod tidy |
| 93 | + fi |
| 94 | +
|
| 95 | + - name: Configure known hosts |
| 96 | + continue-on-error: true |
| 97 | + if: matrix.os != 'ubuntu-latest' |
| 98 | + run: | |
| 99 | + mkdir -p ~/.ssh |
| 100 | + ssh-keyscan -H github.com > ~/.ssh/known_hosts |
| 101 | +
|
| 102 | + - name: Set Git config |
| 103 | + run: | |
| 104 | + git config --global user.email "gha@example.com" |
| 105 | + git config --global user.name "GitHub Actions" |
| 106 | +
|
| 107 | + - name: Test go-git |
| 108 | + working-directory: go-git |
| 109 | + run: go test ./... |
| 110 | + |
| 111 | + - name: Test go-git CLI |
| 112 | + if: ${{ hashFiles('go-git/cli/go-git/go.mod') != '' }} |
| 113 | + working-directory: go-git/cli/go-git |
| 114 | + run: go test ./... |
0 commit comments