github.com/pkujhd/goloader@v0.0.0-20240411034752-1a28096bd7bd/.github/workflows/go.yml (about)

     1  name: goloader Testing
     2  
     3  on:
     4    push:
     5      branches: [ master ]
     6    pull_request:
     7      branches: [ master ]
     8  
     9  jobs:    
    10    build:
    11      env:
    12        GOPATH: ${{ github.workspace }}
    13        GO111MODULE: auto
    14      strategy:
    15        fail-fast: false
    16        matrix:
    17          go-second-version: [8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22]
    18          os:  [ubuntu-latest, windows-latest, macos-latest]
    19          exclude:
    20            - os: macos-latest
    21              go-second-version: 8
    22            - os: macos-latest
    23              go-second-version: 9
    24            - os: macos-latest
    25              go-second-version: 10
    26          include:
    27            - os: macos-11
    28              go-second-version: 8
    29            - os: macos-11
    30              go-second-version: 9
    31            - os: macos-11
    32              go-second-version: 10
    33      runs-on: ${{ matrix.os }}
    34  
    35      steps:
    36      - name: Set up Go
    37        uses: actions/setup-go@v3
    38        with:
    39          go-version: 1.${{ matrix.go-second-version }}.x
    40          
    41      - name: Rename cmd/internal
    42        shell: sh
    43        run:         
    44          cp -r `go env GOROOT`/src/cmd/internal `go env GOROOT`/src/cmd/objfile
    45          
    46      - name: Checkout code
    47        uses: actions/checkout@v3
    48        with:
    49          path: ${{ env.GOPATH }}/src/github.com/${{ github.repository }}
    50        
    51      - name: Build
    52        run:
    53          go build github.com/pkujhd/goloader/examples/loader
    54          
    55      - name: Compile const.go
    56        shell: sh
    57        run: |
    58          if [ ${{ matrix.go-second-version }} -ge 20 ]; then
    59            go list -export -f '{{if .Export}}packagefile {{.ImportPath}}={{.Export}}{{end}}' std `go list -f {{.Imports}} $GOPATH/src/github.com/pkujhd/goloader/examples/const/const.go | awk '{sub(/^\[/, ""); print }' | awk '{sub(/\]$/, ""); print }'` > importcfg
    60            go tool compile -importcfg importcfg $GOPATH/src/github.com/pkujhd/goloader/examples/const/const.go
    61          else
    62            go tool compile $GOPATH/src/github.com/pkujhd/goloader/examples/const/const.go
    63          fi
    64          
    65      - name: Compile base.go
    66        shell: sh
    67        run: |
    68          if [ ${{ matrix.go-second-version }} -ge 20 ]; then
    69            go list -export -f '{{if .Export}}packagefile {{.ImportPath}}={{.Export}}{{end}}' std `go list -f {{.Imports}} $GOPATH/src/github.com/pkujhd/goloader/examples/base/base.go | awk '{sub(/^\[/, ""); print }' | awk '{sub(/\]$/, ""); print }'` > importcfg
    70            go tool compile -importcfg importcfg $GOPATH/src/github.com/pkujhd/goloader/examples/base/base.go
    71          else
    72            go tool compile $GOPATH/src/github.com/pkujhd/goloader/examples/base/base.go
    73          fi
    74          
    75      - name: Test base.o
    76        run: 
    77          ./loader -o base.o -run main.main
    78          
    79      - name: Test const.o
    80        run:
    81          ./loader -o const.o -run main.main