diff options
Diffstat (limited to '.github')
-rw-r--r-- | .github/dependabot.yml | 4 | ||||
-rw-r--r-- | .github/workflows/docker.yml | 59 | ||||
-rw-r--r-- | .github/workflows/tests.yml | 89 |
3 files changed, 113 insertions, 39 deletions
diff --git a/.github/dependabot.yml b/.github/dependabot.yml index d608a8244..07f6b705b 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -4,10 +4,10 @@ updates: - package-ecosystem: "gomod" directory: "/" # Location of package manifests schedule: - interval: "weekly" + interval: "monthly" # Dependencies listed in .github/workflows/*.yml - package-ecosystem: "github-actions" directory: "/" schedule: - interval: "weekly" + interval: "monthly" diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 000000000..43c427109 --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,59 @@ + +name: Create and publish a Docker image + +on: + push: + tags: + - 'v*' + branches: + - 'master' + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + build-and-push-image: + if: github.repository == 'restic/restic' + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Log in to the Container registry + uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=ref,event=branch + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + + - name: Set up QEMU + uses: docker/setup-qemu-action@e81a89b1732b9c48d79cd809d8d81d79c4647a18 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@4b4e9c3e2d4531116a6f8ba8e71fc6e2cb6e6c8c + + - name: Build and push Docker image + uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 + with: + push: true + context: . + file: docker/Dockerfile.release + platforms: linux/386,linux/amd64,linux/arm,linux/arm64 + pull: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 9c9555543..2ec4591f0 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -7,9 +7,13 @@ on: # run tests for all pull requests pull_request: + merge_group: + +permissions: + contents: read env: - latest_go: "1.19.x" + latest_go: "1.20.x" GO111MODULE: on jobs: @@ -19,28 +23,33 @@ jobs: # list of jobs to run: include: - job_name: Windows - go: 1.19.x + go: 1.20.x os: windows-latest - job_name: macOS - go: 1.19.x + go: 1.20.x os: macOS-latest test_fuse: false - job_name: Linux - go: 1.19.x + go: 1.20.x os: ubuntu-latest test_cloud_backends: true test_fuse: true check_changelog: true - job_name: Linux (race) - go: 1.19.x + go: 1.20.x os: ubuntu-latest test_fuse: true test_opts: "-race" - job_name: Linux + go: 1.19.x + os: ubuntu-latest + test_fuse: true + + - job_name: Linux go: 1.18.x os: ubuntu-latest test_fuse: true @@ -53,7 +62,7 @@ jobs: steps: - name: Set up Go ${{ matrix.go }} - uses: actions/setup-go@v3 + uses: actions/setup-go@v4 with: go-version: ${{ matrix.go }} @@ -132,6 +141,14 @@ jobs: run: | go run build.go + - name: Minimal test + run: | + ./restic init + ./restic backup . + env: + RESTIC_REPOSITORY: ../testrepo + RESTIC_PASSWORD: password + - name: Run local Tests env: RESTIC_TEST_FUSE: ${{ matrix.test_fuse }} @@ -179,7 +196,7 @@ jobs: # own repo, otherwise the secrets are not available # Skip for Dependabot pull requests as these are run without secrets # https://docs.github.com/en/code-security/dependabot/working-with-dependabot/automating-dependabot-with-github-actions#responding-to-events - if: (github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository) && (github.actor != 'dependabot[bot]') && matrix.test_cloud_backends + if: ((github.repository == 'restic/restic' && github.event_name == 'push') || github.event.pull_request.head.repo.full_name == github.repository) && (github.actor != 'dependabot[bot]') && matrix.test_cloud_backends - name: Check changelog files with calens run: | @@ -193,56 +210,41 @@ jobs: cross_compile: strategy: - # ATTENTION: the list of architectures must be in sync with helpers/build-release-binaries/main.go! matrix: # run cross-compile in three batches parallel so the overall tests run faster - targets: - - "linux/386 linux/amd64 linux/arm linux/arm64 linux/ppc64le linux/mips linux/mipsle linux/mips64 linux/mips64le linux/riscv64 linux/s390x" - - - "openbsd/386 openbsd/amd64 \ - freebsd/386 freebsd/amd64 freebsd/arm \ - aix/ppc64 \ - darwin/amd64 darwin/arm64" - - - "netbsd/386 netbsd/amd64 \ - windows/386 windows/amd64 \ - solaris/amd64" + subset: + - "0/3" + - "1/3" + - "2/3" env: GOPROXY: https://proxy.golang.org runs-on: ubuntu-latest - name: Cross Compile for ${{ matrix.targets }} + name: Cross Compile for subset ${{ matrix.subset }} steps: - name: Set up Go ${{ env.latest_go }} - uses: actions/setup-go@v3 + uses: actions/setup-go@v4 with: go-version: ${{ env.latest_go }} - - name: Install gox - run: | - go install github.com/mitchellh/gox@latest - - name: Check out code uses: actions/checkout@v3 - - name: Cross-compile with gox for ${{ matrix.targets }} - env: - GOFLAGS: "-trimpath" - GOX_ARCHS: "${{ matrix.targets }}" + - name: Cross-compile for subset ${{ matrix.subset }} run: | - mkdir build-output - gox -parallel 2 -verbose -osarch "$GOX_ARCHS" -output "build-output/{{.Dir}}_{{.OS}}_{{.Arch}}" ./cmd/restic - gox -parallel 2 -verbose -osarch "$GOX_ARCHS" -tags debug -output "build-output/{{.Dir}}_{{.OS}}_{{.Arch}}_debug" ./cmd/restic + mkdir build-output build-output-debug + go run ./helpers/build-release-binaries/main.go -o build-output -s . --platform-subset ${{ matrix.subset }} + go run ./helpers/build-release-binaries/main.go -o build-output-debug -s . --platform-subset ${{ matrix.subset }} --tags debug lint: name: lint runs-on: ubuntu-latest steps: - name: Set up Go ${{ env.latest_go }} - uses: actions/setup-go@v3 + uses: actions/setup-go@v4 with: go-version: ${{ env.latest_go }} @@ -253,9 +255,7 @@ jobs: uses: golangci/golangci-lint-action@v3 with: # Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version. - version: v1.49 - # Optional: show only new issues if it's a pull request. The default value is `false`. - only-new-issues: true + version: v1.52.2 args: --verbose --timeout 5m # only run golangci-lint for pull requests, otherwise ALL hints get @@ -269,6 +269,21 @@ jobs: go mod tidy git diff --exit-code go.mod go.sum + analyze: + name: Analyze results + needs: [test, cross_compile, lint] + if: always() + + permissions: # no need to access code + contents: none + + runs-on: ubuntu-latest + steps: + - name: Decide whether the needed jobs succeeded or failed + uses: re-actors/alls-green@05ac9388f0aebcb5727afa17fcccfecd6f8ec5fe + with: + jobs: ${{ toJSON(needs) }} + docker: name: docker runs-on: ubuntu-latest @@ -301,7 +316,7 @@ jobs: - name: Build and push id: docker_build - uses: docker/build-push-action@v3 + uses: docker/build-push-action@v4 with: push: false context: . |