From ef397c3f49ace0d447957d2813cb9b53312e3b99 Mon Sep 17 00:00:00 2001 From: Alex Turchyn Date: Tue, 4 Jul 2023 00:25:57 +0300 Subject: [PATCH] configure GitHub actions --- .github/workflows/ci.yml | 140 ++++++++++++++++++++++++++++++++++ .github/workflows/docker.yml | 45 +++++++++++ .github/workflows/erblint.yml | 25 ------ .github/workflows/eslint.yml | 28 ------- .github/workflows/rspec.yml | 65 ---------------- .github/workflows/rubocop.yml | 25 ------ .rubocop.yml | 1 + app/views/shared/logo.svg | 38 +++++++++ 8 files changed, 224 insertions(+), 143 deletions(-) create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/docker.yml delete mode 100644 .github/workflows/erblint.yml delete mode 100644 .github/workflows/eslint.yml delete mode 100644 .github/workflows/rspec.yml delete mode 100644 .github/workflows/rubocop.yml create mode 100644 app/views/shared/logo.svg diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 000000000..be8db3ebf --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,140 @@ +--- +name: CI +on: [push] + +jobs: + rubocop: + name: Rubocop + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Install Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: 3.2.2 + - name: Cache gems + uses: actions/cache@v1 + with: + path: vendor/bundle + key: ${{ runner.os }}-gem-${{ hashFiles('**/Gemfile.lock') }} + restore-keys: | + ${{ runner.os }}-gem- + - name: Install gems + run: | + gem install bundler + bundle config path vendor/bundle + bundle install --jobs 4 --retry 4 + - name: Run RuboCop + run: bundle exec rubocop + + erblint: + name: Erblint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Install Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: 3.2.2 + - name: Cache gems + uses: actions/cache@v1 + with: + path: vendor/bundle + key: ${{ runner.os }}-gem-${{ hashFiles('**/Gemfile.lock') }} + restore-keys: | + ${{ runner.os }}-gem- + - name: Install gems + run: | + gem install bundler + bundle config path vendor/bundle + bundle install --jobs 4 --retry 4 + - name: Run Erblint + run: bundle exec erblint ./app + + eslint: + name: ESLint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Install Node.js + uses: actions/setup-node@v1 + with: + node-version: 16.13.1 + - name: Cache directory path + id: yarn-cache-dir-path + run: echo "::set-output name=dir::$(yarn cache dir)" + - uses: actions/cache@v1 + id: yarn-cache + with: + path: ${{ steps.yarn-cache-dir-path.outputs.dir }} + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-yarn- + - name: Install dependencies + run: | + yarn install + - name: Run eslint + run: | + ./node_modules/eslint/bin/eslint.js "app/javascript/**/*.js" + + rspec: + name: RSpec + runs-on: ubuntu-latest + + services: + postgres: + image: postgres:14 + env: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + POSTGRES_DB: docuseal_test + ports: ["5432:5432"] + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + + steps: + - uses: actions/checkout@v2 + - name: Install Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: 3.2.2 + - name: Set up Node + uses: actions/setup-node@v1 + with: + node-version: 16.13.1 + - name: Install Chrome + uses: browser-actions/setup-chrome@latest + - name: Cache node_modules + uses: actions/cache@v1 + with: + path: node_modules + key: ${{ runner.os }}-node-${{ hashFiles('**/yarn.lock') }} + - name: Cache gems + uses: actions/cache@v1 + with: + path: vendor/bundle + key: ${{ runner.os }}-gem-${{ hashFiles('**/Gemfile.lock') }} + restore-keys: | + ${{ runner.os }}-gem- + - name: Install dependencies + env: + RAILS_ENV: test + run: | + gem install bundler + bundle config path vendor/bundle + bundle install --jobs 4 --retry 4 + yarn install + sudo apt-get install libvips + - name: Run + env: + RAILS_ENV: test + NODE_ENV: test + COVERAGE: true + DATABASE_URL: postgres://postgres:postgres@localhost:5432/docuseal_test + run: | + bundle exec rake db:create + bundle exec rake db:migrate + bundle exec rspec diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 000000000..9cd27a223 --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,45 @@ +name: Build Docker Images + +on: + push: + tags: + - "*.*.*" + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + with: + submodules: recursive + + - + name: Docker meta + id: meta + uses: docker/metadata-action@v4 + with: + images: | + docuseal/docuseal + tags: | + type=semver,pattern={{version}} + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Login to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build and push Docker image + uses: docker/build-push-action@v4 + with: + context: . + push: true + platforms: linux/amd64,linux/arm64 + tags: ${{ steps.meta.outputs.tags }} diff --git a/.github/workflows/erblint.yml b/.github/workflows/erblint.yml deleted file mode 100644 index 158cdc9f7..000000000 --- a/.github/workflows/erblint.yml +++ /dev/null @@ -1,25 +0,0 @@ -name: Erblint -on: [push] -jobs: - erblint: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Install Ruby - uses: ruby/setup-ruby@v1 - with: - ruby-version: 3.2.2 - - name: Cache gems - uses: actions/cache@v1 - with: - path: vendor/bundle - key: ${{ runner.os }}-gem-${{ hashFiles('**/Gemfile.lock') }} - restore-keys: | - ${{ runner.os }}-gem- - - name: Install gems - run: | - gem install bundler - bundle config path vendor/bundle - bundle install --jobs 4 --retry 4 - - name: Run Erblint - run: bundle exec erblint ./app diff --git a/.github/workflows/eslint.yml b/.github/workflows/eslint.yml deleted file mode 100644 index e7a7a6026..000000000 --- a/.github/workflows/eslint.yml +++ /dev/null @@ -1,28 +0,0 @@ -name: ESLint -on: [push] -jobs: - eslint: - name: Run ESLint - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Install Node.js - uses: actions/setup-node@v1 - with: - node-version: 16.13.1 - - name: Cache directory path - id: yarn-cache-dir-path - run: echo "::set-output name=dir::$(yarn cache dir)" - - uses: actions/cache@v1 - id: yarn-cache - with: - path: ${{ steps.yarn-cache-dir-path.outputs.dir }} - key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} - restore-keys: | - ${{ runner.os }}-yarn- - - name: Install dependencies - run: | - yarn install - - name: Run eslint - run: | - ./node_modules/eslint/bin/eslint.js "app/javascript/**/*.js" diff --git a/.github/workflows/rspec.yml b/.github/workflows/rspec.yml deleted file mode 100644 index eec999eaf..000000000 --- a/.github/workflows/rspec.yml +++ /dev/null @@ -1,65 +0,0 @@ -name: Rspec -on: push - -jobs: - verify: - name: Build - runs-on: ubuntu-latest - - services: - postgres: - image: postgres:14 - env: - POSTGRES_USER: postgres - POSTGRES_PASSWORD: postgres - POSTGRES_DB: docuseal_test - ports: ["5432:5432"] - options: >- - --health-cmd pg_isready - --health-interval 10s - --health-timeout 5s - --health-retries 5 - - steps: - - uses: actions/checkout@v2 - - name: Install Ruby - uses: ruby/setup-ruby@v1 - with: - ruby-version: 3.2.1 - - name: Set up Node - uses: actions/setup-node@v1 - with: - node-version: 16.13.1 - - name: Install Chrome - uses: browser-actions/setup-chrome@latest - - name: Cache node_modules - uses: actions/cache@v1 - with: - path: node_modules - key: ${{ runner.os }}-node-${{ hashFiles('**/yarn.lock') }} - - name: Cache gems - uses: actions/cache@v1 - with: - path: vendor/bundle - key: ${{ runner.os }}-gem-${{ hashFiles('**/Gemfile.lock') }} - restore-keys: | - ${{ runner.os }}-gem- - - name: Install dependencies - env: - RAILS_ENV: test - run: | - gem install bundler - bundle config path vendor/bundle - bundle install --jobs 4 --retry 4 - yarn install - - name: Run - env: - RAILS_ENV: test - NODE_ENV: test - COVERAGE: true - DATABASE_URL: postgres://postgres:postgres@localhost:5432/docuseal_test - run: | - bundle exec rake db:create - bundle exec rake db:migrate - bundle exec rake assets:precompile - bundle exec rspec diff --git a/.github/workflows/rubocop.yml b/.github/workflows/rubocop.yml deleted file mode 100644 index b591c79e7..000000000 --- a/.github/workflows/rubocop.yml +++ /dev/null @@ -1,25 +0,0 @@ -name: Rubocop -on: [push] -jobs: - rubocop: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Install Ruby - uses: ruby/setup-ruby@v1 - with: - ruby-version: 3.2.2 - - name: Cache gems - uses: actions/cache@v1 - with: - path: vendor/bundle - key: ${{ runner.os }}-gem-${{ hashFiles('**/Gemfile.lock') }} - restore-keys: | - ${{ runner.os }}-gem- - - name: Install gems - run: | - gem install bundler - bundle config path vendor/bundle - bundle install --jobs 4 --retry 4 - - name: Run RuboCop - run: bundle exec rubocop diff --git a/.rubocop.yml b/.rubocop.yml index 3926846b0..0b6c8596f 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -9,6 +9,7 @@ AllCops: - db/schema.rb - node_modules/**/* - bin/* + - vendor/**/* TargetRubyVersion: '3.2' Metrics/BlockLength: diff --git a/app/views/shared/logo.svg b/app/views/shared/logo.svg new file mode 100644 index 000000000..f41b7b6d5 --- /dev/null +++ b/app/views/shared/logo.svg @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + +