Skip to content

Commit

Permalink
CLOUDP-79093: [mongocli] move to github actions (#548)
Browse files Browse the repository at this point in the history
  • Loading branch information
gssbzn committed Dec 16, 2020
1 parent 8b726bd commit cc4762d
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 40 deletions.
33 changes: 0 additions & 33 deletions .drone.yml

This file was deleted.

38 changes: 38 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
name: CI
on: [push, pull_request]
jobs:
golangci-lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: lint
uses: golangci/golangci-lint-action@v2.3.0
with:
version: v1.33.0

tests:
needs: golangci-lint # run after golangci-lint action to not produce duplicated errors
strategy:
fail-fast: false
matrix:
golang: [1.15]
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}

steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.golang }}
- name: Cache Dependencies
uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ matrix.golang }}-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-${{ matrix.golang }}-
- name: Run tests
run: make test
15 changes: 15 additions & 0 deletions .github/workflows/security.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
name: Snyk
on:
push:
branches:
- master
jobs:
security:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Run Snyk to check for vulnerabilities
uses: snyk/actions/golang@master
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ e2e-test: build ## Run E2E tests
.PHONY: integration-test
integration-test: ## Run integration tests
@echo "==> Running integration tests..."
${TEST_CMD} --tags="${INTEGRATION_TAGS}" ./internal...
${TEST_CMD} --tags="${INTEGRATION_TAGS}" -count=1 ./internal...

.PHONY: unit-test
unit-test: ## Run unit-tests
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
</p>


[![Build Status](https://cloud.drone.io/api/badges/mongodb/mongocli/status.svg)](https://cloud.drone.io/mongodb/mongocli)
![CI](https://github.com/mongodb/mongocli/workflows/CI/badge.svg)

`mongocli` is a tool for managing your MongoDB cloud services

Expand Down
6 changes: 3 additions & 3 deletions internal/config/profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ package config

import (
"errors"
"fmt"
"log"
"path/filepath"
"sort"
"strings"

Expand Down Expand Up @@ -313,7 +313,7 @@ func (p *Profile) Delete() error {
}

func (p *Profile) Filename() string {
return fmt.Sprintf("%s/%s.toml", p.configDir, ToolName)
return filepath.Join(p.configDir, ToolName+".toml")
}

// Rename replaces the Profile to a new Profile name, overwriting any Profile that existed before.
Expand Down Expand Up @@ -392,6 +392,6 @@ func (p *Profile) Save() error {
return err
}
}
configFile := fmt.Sprintf("%s/%s.toml", p.configDir, ToolName)
configFile := p.Filename()
return viper.WriteConfigAs(configFile)
}
8 changes: 6 additions & 2 deletions internal/config/profile_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package config

import (
"path/filepath"
"testing"

"github.com/spf13/afero"
Expand All @@ -30,15 +31,18 @@ const (

func testProfile(profileContents string) *Profile {
fs := afero.NewMemMapFs()
testConfigDir := "/test"
testConfigDir, _ := filepath.Abs("test")

p := &Profile{
name: DefaultProfile,
configDir: testConfigDir,
fs: fs,
}

_ = afero.WriteFile(fs, p.Filename(), []byte(profileContents), 0600)
if err := afero.WriteFile(fs, p.Filename(), []byte(profileContents), 0600); err != nil {
panic(err)
}

return p
}

Expand Down

0 comments on commit cc4762d

Please sign in to comment.