Skip to content

Commit

Permalink
Merge branch 'develop' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
7R41N33 committed Mar 28, 2022
2 parents ba2994f + f6418af commit 7b4f542
Show file tree
Hide file tree
Showing 46 changed files with 987 additions and 100 deletions.
9 changes: 9 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/.bundle/
/.yardoc
/_yardoc/
/coverage/
/doc/
/pkg/
/spec/reports/
/tmp/
.byebug_history
38 changes: 31 additions & 7 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
name: Uffizzi CLI CI/CD
name: Test, Lint, Build, and Publish Image
on:
push:
branches:
- "**"
- qa
- develop
- main
pull_request:
types: [opened,synchronize,reopened]

jobs:
lint:
runs-on: ubuntu-latest
Expand All @@ -26,10 +31,12 @@ jobs:
bundler-cache: true
- name: Run tests
run: bundle exec rake test
deploy:
build-and-push-some-branches:
runs-on: ubuntu-latest
needs: [lint, test]
if: github.ref == 'refs/heads/main'
needs:
- lint
- test
if: ${{ github.ref_name == 'main' || github.ref_name == 'qa' || github.ref_name == 'develop' || github.event_name == 'pull_request' }}
steps:
- name: Checkout
uses: actions/checkout@v2
Expand All @@ -40,8 +47,25 @@ jobs:
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
- name: Docker metadata
id: meta
uses: docker/metadata-action@v3
with:
images: uffizzi/cli
tags: |
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }}
type=ref,event=branch,enable=${{ github.ref_name == 'qa' || github.ref_name == 'develop' }}
type=ref,event=pr
- name: Build and Push Image to Docker Hub
uses: docker/build-push-action@v2
with:
push: true
tags: uffizzi/cli:latest
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Update Docker Hub Description for Default Branch
uses: peter-evans/[email protected]
if: ${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }}
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
repository: uffizzi/cli
45 changes: 34 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,23 +1,46 @@
FROM ruby:3.0.2-alpine3.14
FROM ruby:3.0.3-alpine AS builder

RUN apk update && apk upgrade
RUN apk add bash
RUN apk add curl-dev ruby-dev build-base git curl ruby-json openssl groff mandoc man-pages
RUN apk --update add --no-cache \
curl-dev \
ruby-dev \
build-base \
git \
curl \
ruby-json \
openssl \
groff \
mandoc \
man-pages \
bash

RUN mkdir -p /gem
WORKDIR /gem

ENV GEM_HOME="/usr/local/bundle"
ENV PATH $GEM_HOME/bin:$GEM_HOME/gems/bin:$PATH

RUN gem install uffizzi-cli
RUN gem install bundler -v 2.3.8
RUN gem install bundler -v 2.3.9

COPY lib/uffizzi/version.rb /gem/lib/uffizzi/
COPY uffizzi.gemspec /gem/
COPY Gemfile* /gem/
COPY lib/uffizzi/version.rb ./lib/uffizzi/
COPY uffizzi.gemspec .
COPY Gemfile* .
RUN bundle install --jobs 4

COPY . /gem
COPY . .

CMD ["uffizzi"]
RUN bundle exec rake install

# M-M-M-M-MULTISTAGE!!!
FROM ruby:3.0.3-alpine

RUN apk --update add --no-cache mandoc

WORKDIR /root/

COPY docker-entrypoint.sh .
RUN chmod +x docker-entrypoint.sh

COPY --from=builder /gem/pkg/uffizzi-cli* .
RUN gem install ./uffizzi-cli*

ENTRYPOINT ["/root/docker-entrypoint.sh"]
7 changes: 6 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
uffizzi-cli (0.2.2)
uffizzi-cli (0.3.2)
thor

GEM
Expand All @@ -16,13 +16,16 @@ GEM
addressable (2.8.0)
public_suffix (>= 2.0.2, < 5.0)
ast (2.4.2)
bump (0.10.0)
byebug (11.1.3)
coderay (1.1.3)
concurrent-ruby (1.1.9)
crack (0.4.5)
rexml
factory_bot (6.2.0)
activesupport (>= 5.0.0)
faker (2.20.0)
i18n (>= 1.8.11, < 2)
hashdiff (1.0.1)
i18n (1.8.11)
concurrent-ruby (~> 1.0)
Expand Down Expand Up @@ -95,9 +98,11 @@ PLATFORMS
x86_64-linux-musl

DEPENDENCIES
bump
bundler (~> 2.2)
byebug
factory_bot
faker
minitest
minitest-power_assert
mocha
Expand Down
39 changes: 33 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ To host Uffizzi yourself, you will also need the following external dependencies

## Installation

Add this line to your application's Gemfile:
Add this line to your application's `Gemfile`:

```ruby
gem 'uffizzi'
gem 'uffizzi-cli'
```

And then execute:
Expand All @@ -41,7 +41,23 @@ And then execute:

Or install it yourself as:

$ gem install uffizzi
$ gem install uffizzi-cli

### Docker image

We also provide an image on Docker Hub:

```bash
docker run -it --rm uffizzi/cli project list
```

If you specify the following environment variables, the Docker image's
entrypoint script can log you into Uffizzi before executing your command.

- `UFFIZZI_USER`
- `UFFIZZI_HOSTNAME`
- `UFFIZZI_PASSWORD`
- `UFFIZZI_PROJECT` (optional)

## Development

Expand All @@ -52,12 +68,23 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
Run rubocop:
`bundle exec rubocop -A`

## Testing

Run tests:
`bundle exec rake test`

Run tests from a file:
`bundle exec rake test TEST=test/uffizzi/cli/preview_test.rb`

Run single test
`bundle exec rake test TEST=test/uffizzi/cli/preview_test.rb TESTOPTS="--name=test_name"`

## Commands

### login

```
$ uffizzi login -u [email protected] --hostname localhost:8080
$ uffizzi login --user [email protected] --hostname localhost:8080
```

Logging you into the app which you set in the hostname option.
Expand Down Expand Up @@ -167,7 +194,7 @@ git checkout -b feature/short_issue_description (e.g. feature/add_domain_setting
```
git add .
git commit -m 'short commit description' (e.g. git commit -m 'added domain settings')
git push origin FEATURE_NAME
git push origin BRANCH_NAME
```

4. You already can create PR with develop branch as a target. Once the feature is ready let us know in the channel - we will review
Expand All @@ -176,7 +203,7 @@ git push origin FEATURE_NAME
```
git checkout qa
git pull --rebase qa
git merge --no-ff FEATURE_NAME
git merge --no-ff BRANCH_NAME
git push origin qa
```

Expand Down
17 changes: 0 additions & 17 deletions config/config.rb

This file was deleted.

7 changes: 7 additions & 0 deletions config/uffizzi.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# frozen_string_literal: true

require 'ostruct'

module Uffizzi
def self.configuration
@configuration ||= OpenStruct.new
Expand All @@ -12,5 +13,11 @@ def self.configure

configure do |config|
config.hostname = 'http://web:7000'
config.credential_types = {
dockerhub: 'UffizziCore::Credential::DockerHub',
azure: 'UffizziCore::Credential::Azure',
google: 'UffizziCore::Credential::Google',
amazon: 'UffizziCore::Credential::Amazon',
}
end
end
4 changes: 3 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ version: "3.9"

services:
gem:
build: .
build:
context: .
target: builder
volumes:
- ./:/gem:cached
- ~/.ssh:/root/.ssh
Expand Down
20 changes: 20 additions & 0 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/sh

set -e # Exit immediately if anything below exits with non-zero status.

if
[ $UFFIZZI_USER ] &&
[ $UFFIZZI_HOSTNAME ] &&
[ $UFFIZZI_PASSWORD ]
then
uffizzi login --username "${UFFIZZI_USER}" --hostname "${UFFIZZI_HOSTNAME}"
if [ $UFFIZZI_PROJECT ]
then
uffizzi config set project "${UFFIZZI_PROJECT}"
fi
else
echo "Specify environment variables to login before executing Uffizzi CLI."
echo "UFFIZZI_USER, UFFIZZI_HOSTNAME, UFFIZZI_PASSWORD, and optionally UFFIZZI_PROJECT"
fi

exec uffizzi "$@"
3 changes: 3 additions & 0 deletions lib/uffizzi.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
# frozen_string_literal: true

require 'io/console'

require 'uffizzi/shell'
require 'uffizzi/version'
require 'uffizzi/clients/api/api_client'
require 'uffizzi/clients/api/api_routes'
require 'uffizzi/config_file'
require_relative '../config/uffizzi'

module Uffizzi
class Error < StandardError; end
Expand Down
12 changes: 12 additions & 0 deletions lib/uffizzi/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ def logout(help = nil)
Logout.new.run
end

desc 'projects', 'projects'
def projects
require_relative 'cli/projects'
Projects.new.run
end

desc 'project', 'project'
require_relative 'cli/project'
subcommand 'project', CLI::Project
Expand All @@ -42,5 +48,11 @@ def logout(help = nil)
method_option :project, required: false
require_relative 'cli/preview'
subcommand 'preview', CLI::Preview

desc 'connect CREDENTIAL_TYPE', 'Connect credentials into Uffizzi'
def connect(credential_type, credential_file_path = nil)
require_relative 'cli/connect'
Connect.new.run(credential_type, credential_file_path)
end
end
end
1 change: 0 additions & 1 deletion lib/uffizzi/cli/config.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# frozen_string_literal: true

require 'io/console'
require 'uffizzi'
require 'uffizzi/clients/api/api_client'

Expand Down
Loading

0 comments on commit 7b4f542

Please sign in to comment.