From f8635059e499ddee7e2e7e275e7ee5a2377a8d8a Mon Sep 17 00:00:00 2001 From: iotanbo Date: Fri, 29 Oct 2021 13:11:25 +0300 Subject: [PATCH] Add github actions for CI --- .github/workflows/macos-latest.yml | 26 +++++++ .github/workflows/ubuntu-latest.yml | 26 +++++++ .github/workflows/windows-latest.yml | 26 +++++++ README.md | 2 +- azure-pipelines.yml | 111 --------------------------- 5 files changed, 79 insertions(+), 112 deletions(-) create mode 100644 .github/workflows/macos-latest.yml create mode 100644 .github/workflows/ubuntu-latest.yml create mode 100644 .github/workflows/windows-latest.yml delete mode 100644 azure-pipelines.yml diff --git a/.github/workflows/macos-latest.yml b/.github/workflows/macos-latest.yml new file mode 100644 index 00000000..0b3ffcca --- /dev/null +++ b/.github/workflows/macos-latest.yml @@ -0,0 +1,26 @@ +name: Macos-latest + +on: [push, pull_request] + +jobs: + + build-and-test: + + strategy: + matrix: + go-version: [1.13, 1.17] + runs-on: macos-latest + steps: + - name: Install Go + uses: actions/setup-go@v2 + with: + go-version: ${{ matrix.go-version }} + + - name: Checkout code + uses: actions/checkout@v2 + + - name: Build + run: go build cmd/arc/main.go + + - name: Test + run: go test -v ./... diff --git a/.github/workflows/ubuntu-latest.yml b/.github/workflows/ubuntu-latest.yml new file mode 100644 index 00000000..d13cd3e0 --- /dev/null +++ b/.github/workflows/ubuntu-latest.yml @@ -0,0 +1,26 @@ +name: Ubuntu-latest + +on: [push, pull_request] + +jobs: + + build-and-test: + + strategy: + matrix: + go-version: [1.13, 1.17] + runs-on: ubuntu-latest + steps: + - name: Install Go + uses: actions/setup-go@v2 + with: + go-version: ${{ matrix.go-version }} + + - name: Checkout code + uses: actions/checkout@v2 + + - name: Build + run: go build cmd/arc/main.go + + - name: Test + run: go test -v ./... diff --git a/.github/workflows/windows-latest.yml b/.github/workflows/windows-latest.yml new file mode 100644 index 00000000..e9b95d1f --- /dev/null +++ b/.github/workflows/windows-latest.yml @@ -0,0 +1,26 @@ +name: Windows-latest + +on: [push, pull_request] + +jobs: + + build-and-test: + + strategy: + matrix: + go-version: [1.13, 1.17] + runs-on: windows-latest + steps: + - name: Install Go + uses: actions/setup-go@v2 + with: + go-version: ${{ matrix.go-version }} + + - name: Checkout code + uses: actions/checkout@v2 + + - name: Build + run: go build cmd/arc/main.go + + - name: Test + run: go test -v ./... diff --git a/README.md b/README.md index 5ea9833e..c8de5e7e 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# archiver [![archiver GoDoc](https://img.shields.io/badge/reference-godoc-blue.svg?style=flat-square)](https://pkg.go.dev/github.com/mholt/archiver?tab=doc) +# archiver [![archiver GoDoc](https://img.shields.io/badge/reference-godoc-blue.svg?style=flat-square)](https://pkg.go.dev/github.com/mholt/archiver?tab=doc) [![Ubuntu-latest](https://github.com/mholt/archiver/actions/workflows/ubuntu-latest.yml/badge.svg)](https://github.com/mholt/archiver/actions/workflows/ubuntu-latest.yml) [![Macos-latest](https://github.com/mholt/archiver/actions/workflows/macos-latest.yml/badge.svg)](https://github.com/mholt/archiver/actions/workflows/macos-latest.yml) [![Windows-latest](https://github.com/mholt/archiver/actions/workflows/windows-latest.yml/badge.svg)](https://github.com/mholt/archiver/actions/workflows/windows-latest.yml) Introducing **Archiver 3.1** - a cross-platform, multi-format archive utility and Go library. A powerful and flexible library meets an elegant CLI in this generic replacement for several platform-specific or format-specific archive utilities. diff --git a/azure-pipelines.yml b/azure-pipelines.yml deleted file mode 100644 index 672dce35..00000000 --- a/azure-pipelines.yml +++ /dev/null @@ -1,111 +0,0 @@ -trigger: -- master - -strategy: - matrix: - linux: - imageName: ubuntu-18.04 - gorootDir: /usr/local - mac: - # Mojave - imageName: macos-10.14 - gorootDir: /usr/local - windows: - imageName: windows-2019 - gorootDir: C:\ - -pool: - vmImage: $(imageName) - -variables: - GOROOT: $(gorootDir)/go - GOPATH: $(system.defaultWorkingDirectory)/gopath - GOBIN: $(GOPATH)/bin - modulePath: '$(GOPATH)/src/github.com/$(build.repository.name)' - # TODO: Enable modules after upstream dependency zstd supports them - # TODO: modules should be the default in Go 1.13, so this won't be needed - #GO111MODULE: on - -steps: - -- bash: git config --global core.autocrlf false - displayName: "Disable line ending conversion for git to" - -- checkout: self - -- bash: | - latestGo=$(curl "https://golang.org/VERSION?m=text") - echo "##vso[task.setvariable variable=LATEST_GO]$latestGo" - echo "Latest Go version: $latestGo" - displayName: "Get latest Go version" - -- bash: | - sudo rm -f $(which go) - echo '##vso[task.prependpath]$(GOBIN)' - echo '##vso[task.prependpath]$(GOROOT)/bin' - mkdir -p '$(modulePath)' - shopt -s extglob - shopt -s dotglob - mv !(gopath) '$(modulePath)' - displayName: Remove old Go, set GOBIN/GOROOT, and move project into GOPATH - -# Install Go (this varies by platform) - -- bash: | - wget "https://dl.google.com/go/$(LATEST_GO).linux-amd64.tar.gz" - sudo tar -C $(gorootDir) -xzf "$(LATEST_GO).linux-amd64.tar.gz" - condition: eq( variables['Agent.OS'], 'Linux' ) - displayName: Install Go on Linux - -- bash: | - wget "https://dl.google.com/go/$(LATEST_GO).darwin-amd64.tar.gz" - sudo tar -C $(gorootDir) -xzf "$(LATEST_GO).darwin-amd64.tar.gz" - condition: eq( variables['Agent.OS'], 'Darwin' ) - displayName: Install Go on macOS - -- powershell: | - echo "Downloading Go..." - # Windows comes with BSD curl, which is MUCH faster than the native Windows HTTP - curl.exe -fsSL -o "$(LATEST_GO).windows-amd64.zip" "https://dl.google.com/go/$(LATEST_GO).windows-amd64.zip" - echo "Extracting Go..." - # Yes, Windows tar (BSD tar) handles zip files. Who knew!? - # (and it's MUCH, MUCH, MUCH faster than the native Windows expander) - tar.exe xf "$(LATEST_GO).windows-amd64.zip" -C "$(gorootDir)" - condition: eq( variables['Agent.OS'], 'Windows_NT' ) - displayName: Install Go on Windows - -- bash: | - printf "Using go at: $(which go)\n" - printf "Go version: $(go version)\n" - printf "\n\nGo environment:\n\n" - go env - printf "\n\nSystem environment:\n\n" - env - displayName: Print Go version and environment - -- script: | - curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.31.0 - ./bin/golangci-lint run -E gofmt -E goimports -E misspell ./... - workingDirectory: '$(modulePath)' - condition: eq( variables['Agent.OS'], 'Linux' ) - displayName: Run Lint - -- bash: | - go mod tidy - if [ ! -z "$(git status --porcelain go.mod)" ]; then - printf "go.mod has modifications\n" - git diff go.mod - exit 1 - fi - if [ ! -z "$(git status --porcelain go.sum)" ]; then - printf "go.sum has modifications\n" - git diff go.sum - exit 1 - fi - workingDirectory: '$(modulePath)' - displayName: Ensure that module definition and checksums are correct - -- script: | - go test -race ./... - workingDirectory: '$(modulePath)' - displayName: Run tests