Skip to content

Commit

Permalink
GitHub: Refactor GitHub user data download code (#65)
Browse files Browse the repository at this point in the history
- Refactoring of the GitHub user data download code (including org migrations)
- Add tests for coverage
- Cleanup - remove unused travis CI files
- Add GitHub action for CI on Linux, MacOS and Windows
- Remove appveyor CI
  • Loading branch information
amitsaha authored Dec 30, 2021
1 parent 2c7432c commit 96ffbae
Show file tree
Hide file tree
Showing 16 changed files with 545 additions and 182 deletions.
3 changes: 0 additions & 3 deletions .github/FUNDING.yml

This file was deleted.

48 changes: 48 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: CI
on:
push:
branches: [ master ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ master ]

jobs:
linux_tests:
runs-on: ubuntu-latest
strategy:
matrix:
go: [ '1.16', '1.17' ]
name: Go ${{ matrix.go }} tests - Linux
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go }}
- run: go test

macos_tests:
runs-on: macOS-latest
strategy:
matrix:
go: [ '1.16', '1.17' ]
name: Go ${{ matrix.go }} tests - MacOS
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go }}
- run: go test

windows_tests:
runs-on: windows-latest
strategy:
matrix:
go: [ '1.16', '1.17' ]
name: Go ${{ matrix.go }} tests - Windows
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go }}
- run: go test

2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
strategy:
fail-fast: false
matrix:
language: [ 'go', 'python' ]
language: [ 'go']
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
# Learn more:
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.15
go-version: 1.17
-
name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
Expand Down
25 changes: 0 additions & 25 deletions .travis.yml

This file was deleted.

24 changes: 23 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,28 @@
# gitbackup - Backup your GitHub, GitLab, and Bitbucket repositories
Code Quality [![Go Report Card](https://goreportcard.com/badge/github.com/amitsaha/gitbackup)](https://goreportcard.com/report/github.com/amitsaha/gitbackup)
Linux/Mac OS X [![Build Status](https://travis-ci.org/amitsaha/gitbackup.svg?branch=master)](https://travis-ci.org/amitsaha/gitbackup) Windows [![Build status](https://ci.appveyor.com/api/projects/status/fwki40x1havyian2/branch/master?svg=true)](https://ci.appveyor.com/project/amitsaha/gitbackup/branch/master)
[![.github/workflows/ci.yml](https://github.com/amitsaha/gitbackup/actions/workflows/ci.yml/badge.svg)](https://github.com/amitsaha/gitbackup/actions/workflows/ci.yml)

- [gitbackup - Backup your GitHub, GitLab, and Bitbucket repositories](#gitbackup---backup-your-github-gitlab-and-bitbucket-repositories)
- [Introduction](#introduction)
- [Installing `gitbackup`](#installing-gitbackup)
- [Using `gitbackup`](#using-gitbackup)
- [GitHub Specific oAuth App Flow](#github-specific-oauth-app-flow)
- [OAuth Scopes/Permissions required](#oauth-scopespermissions-required)
- [Bitbucket](#bitbucket)
- [GitHub](#github)
- [GitLab](#gitlab)
- [Security and credentials](#security-and-credentials)
- [Examples](#examples)
- [Backing up your GitHub repositories](#backing-up-your-github-repositories)
- [Backing up your GitLab repositories](#backing-up-your-gitlab-repositories)
- [GitHub Enterprise or custom GitLab installation](#github-enterprise-or-custom-gitlab-installation)
- [Backing up your Bitbucket repositories](#backing-up-your-bitbucket-repositories)
- [Specifying a backup location](#specifying-a-backup-location)
- [Cloning bare repositories](#cloning-bare-repositories)
- [GitHub Migrations](#github-migrations)
- [Building](#building)

## Introduction

``gitbackup`` is a tool to backup your git repositories from GitHub (including GitHub enterprise),
GitLab (including custom GitLab installations), or Bitbucket.
Expand Down
1 change: 0 additions & 1 deletion VERSION

This file was deleted.

22 changes: 0 additions & 22 deletions appveyor.yml

This file was deleted.

12 changes: 0 additions & 12 deletions build-binaries.bash

This file was deleted.

26 changes: 0 additions & 26 deletions build-binaries.py

This file was deleted.

9 changes: 0 additions & 9 deletions check_test.bash

This file was deleted.

14 changes: 10 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"log"
"net/url"
"sync"
"time"

"github.com/google/go-github/v34/github"
)
Expand Down Expand Up @@ -122,15 +123,19 @@ func main() {
}

if *githubWaitForMigrationComplete {
downloadGithubUserMigrationData(client, *backupDir, m.ID)
migrationStatePollingDuration := 60 * time.Second
err = downloadGithubUserMigrationData(context.Background(), client, *backupDir, m.ID, migrationStatePollingDuration)
if err != nil {
log.Fatalf("Error querying/downloading migration: %v", err)
}
}

orgs, err := getUserOwnedOrgs(client)
orgs, err := getGithubUserOwnedOrgs(context.Background(), client)
if err != nil {
log.Fatal("Error getting user organizations", err)
}
for _, o := range orgs {
orgRepos, err := getGithubOrgRepositories(client, o)
orgRepos, err := getGithubOrgRepositories(context.Background(), client, o)
if err != nil {
log.Fatal("Error getting org repos", err)
}
Expand All @@ -144,7 +149,8 @@ func main() {
log.Fatalf("Error creating migration: %v", err)
}
if *githubWaitForMigrationComplete {
downloadGithubOrgMigrationData(client, *o.Login, *backupDir, oMigration.ID)
migrationStatePollingDuration := 60 * time.Second
downloadGithubOrgMigrationData(context.Background(), client, *o.Login, *backupDir, oMigration.ID, migrationStatePollingDuration)
}
}

Expand Down
7 changes: 0 additions & 7 deletions release.bash

This file was deleted.

Loading

0 comments on commit 96ffbae

Please sign in to comment.