Skip to content

Commit

Permalink
Merge pull request #124 from RedTurtle/main
Browse files Browse the repository at this point in the history
Release v7.0.0
  • Loading branch information
pnicolli authored Jan 11, 2023
2 parents 7bb69fc + 018701c commit e064a32
Show file tree
Hide file tree
Showing 419 changed files with 6,780 additions and 8,383 deletions.
2 changes: 0 additions & 2 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,3 @@ node_modules
npm-debug.log*
omelette
.vscode/
.yarn/
.yarnrc
52 changes: 37 additions & 15 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,51 @@
const fs = require('fs');
const path = require('path');
const projectRootPath = path.resolve('.');
const projectRootPath = __dirname;
const packageJson = require(path.join(projectRootPath, 'package.json'));

// Extends ESlint configuration for adding the aliases to `src` directories in Volto addons
const addonsAliases = [];
if (packageJson.addons) {
const addons = packageJson.addons;
addons.forEach((addon) => {
// TODO deprecated: remove in version 8
const addonPath = `@italia/addons/${addon}/src`;
addonsAliases.push([`@italia/addons/${addon}`, addonPath]);
});
let voltoPath = './node_modules/@plone/volto';

let configFile;
if (fs.existsSync(`${projectRootPath}/tsconfig.json`))
configFile = `${projectRootPath}/tsconfig.json`;
else if (fs.existsSync(`${projectRootPath}/jsconfig.json`))
configFile = `${projectRootPath}/jsconfig.json`;

if (configFile) {
const jsConfig = require(configFile).compilerOptions;
const pathsConfig = jsConfig.paths;
if (pathsConfig['@plone/volto'])
voltoPath = `./${jsConfig.baseUrl}/${pathsConfig['@plone/volto'][0]}`;
}

const AddonConfigurationRegistry = require(`${voltoPath}/addon-registry.js`);
const reg = new AddonConfigurationRegistry(__dirname);

// Extends ESlint configuration for adding the aliases to `src` directories in Volto addons
const addonAliases = Object.keys(reg.packages).map((o) => [
o,
reg.packages[o].modulePath,
]);

// TODO deprecated: remove in version 8
const italiaAddonAliases = Object.keys(reg.packages).map((o) => [
`@italia/addons/${o}`,
reg.packages[o].modulePath,
]);

module.exports = {
extends: './node_modules/@plone/volto/.eslintrc',
extends: `${voltoPath}/.eslintrc`,
settings: {
'import/resolver': {
alias: {
map: [
['@plone/volto', '@plone/volto/src'],
['@package', './src'],
['@italia', './src'], // TODO deprecated: remove in version 8
['design-volto-theme', './src'],
['@plone/volto-slate', '@plone/volto/packages/volto-slate/src'],
['design-comuni-plone-theme', `${__dirname}/src`],
...addonAliases,
...italiaAddonAliases,
['@package', `${__dirname}/src`],
['@italia', `${__dirname}/src`], // TODO deprecated: remove in version 8
// TODO remove the next two when implemented in core
[
'@plone/volto/components/theme/Image/Image',
Expand All @@ -32,7 +55,6 @@ module.exports = {
'@plone/volto/helpers/Image/Image',
path.resolve(`${projectRootPath}/src/components/Image/helpers.js`),
],
...addonsAliases,
],
extensions: ['.js', '.jsx', '.json'],
},
Expand Down
149 changes: 72 additions & 77 deletions .github/workflows/bundle_size.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,101 +8,96 @@ jobs:
name: Build base
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: develop
# ref: ${{ github.base_ref }}
- uses: actions/setup-node@v3
with:
node-version: 16
- name: Checkout
uses: actions/checkout@v3
with:
ref: develop
# ref: ${{ github.base_ref }}
- uses: actions/setup-node@v3
with:
node-version: 16

- name: Install dependencies
run: yarn set version 3.2.3 && yarn --immutable
env:
NODE_AUTH_TOKEN: ${{secrets.TOKEN_REPO}}
- name: Install dependencies
run: yarn set version 3.2.3 && yarn --immutable
env:
NODE_AUTH_TOKEN: ${{secrets.TOKEN_REPO}}

- name: Dev requirements
run: yarn develop
env:
NODE_AUTH_TOKEN: ${{secrets.TOKEN_REPO}}
- name: Build
run: yarn run analyze
env:
OFFLINE_BUNDLE_ANALYZE: true
BUNDLE_ANALYZE: true

- name: Build
run: yarn run analyze
env:
OFFLINE_BUNDLE_ANALYZE: true
BUNDLE_ANALYZE: true

- name: Upload base stats.json
uses: actions/upload-artifact@v2
with:
name: base
path: ./build/public/stats.json
retention-days: 1
- name: Upload base stats.json
uses: actions/upload-artifact@v2
with:
name: base
path: ./build/public/stats.json
retention-days: 1

build-pr:
name: Build PR
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
- name: Install dependencies
run: yarn set version 3.2.3 && yarn --immutable
env:
NODE_AUTH_TOKEN: ${{secrets.TOKEN_REPO}}
- name: Checkout
uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
- name: Install dependencies
run: yarn set version 3.2.3 && yarn --immutable
env:
NODE_AUTH_TOKEN: ${{secrets.TOKEN_REPO}}

- name: Build
run: yarn run analyze
env:
OFFLINE_BUNDLE_ANALYZE: true
BUNDLE_ANALYZE: true
- name: Build
run: yarn run analyze
env:
OFFLINE_BUNDLE_ANALYZE: true
BUNDLE_ANALYZE: true

- name: Upload base stats.json
uses: actions/upload-artifact@v2
with:
name: pr
path: ./build/public/stats.json
retention-days: 1
- name: Upload base stats.json
uses: actions/upload-artifact@v2
with:
name: pr
path: ./build/public/stats.json
retention-days: 1

report:
name: Generate report
runs-on: ubuntu-latest
needs: [build-base, build-pr]

steps:
- name: Checkout PR
uses: actions/checkout@v2
- name: Checkout PR
uses: actions/checkout@v2

- name: Download base stats
uses: actions/download-artifact@v2
with:
name: base
path: base
- name: Download base stats
uses: actions/download-artifact@v2
with:
name: base
path: base

- name: Download PR stats
uses: actions/download-artifact@v2
with:
name: pr
path: pr
- name: Download PR stats
uses: actions/download-artifact@v2
with:
name: pr
path: pr

- name: Get diff
id: get-diff
uses: NejcZdovc/bundle-size-diff@v1
with:
base_path: './base/stats.json'
pr_path: './pr/stats.json'
excluded_assets: '\.map$'
- name: Get diff
id: get-diff
uses: NejcZdovc/bundle-size-diff@v1
with:
base_path: './base/stats.json'
pr_path: './pr/stats.json'
excluded_assets: '\.map$'

- name: Comment
uses: NejcZdovc/comment-pr@v1
with:
file: 'bundle_size_comment.md'
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
OLD: ${{steps.get-diff.outputs.base_file_string}}
NEW: ${{steps.get-diff.outputs.pr_file_string}}
DIFF: ${{steps.get-diff.outputs.diff_file_string}}
DIFF_PERCENT: ${{steps.get-diff.outputs.percent}}
- name: Comment
uses: NejcZdovc/comment-pr@v2
with:
file: 'bundle_size_comment.md'
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
OLD: ${{steps.get-diff.outputs.base_file_string}}
NEW: ${{steps.get-diff.outputs.pr_file_string}}
DIFF: ${{steps.get-diff.outputs.diff_file_string}}
DIFF_PERCENT: ${{steps.get-diff.outputs.percent}}
21 changes: 7 additions & 14 deletions .github/workflows/develop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,12 @@ jobs:
# with:
# ref: develop

# - name: Set up QEMU
# uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2

- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Login to DockerHub
uses: docker/login-action@v2
with:
Expand All @@ -43,14 +37,13 @@ jobs:
- name: Build and push Docker images
uses: docker/build-push-action@v3
with:
# List of tags
context: .
tags: redturtletech/io-comune-base:develop
pull: true
# Push is a shorthand for --output=type=registry
push: true
builder: ${{ steps.buildx.outputs.name }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
cache-from: type=registry,ref=redturtletech/io-comune-base:develop
cache-to: type=inline
# platforms: linux/amd64,linux/arm64

- name: Deploy to rancher
uses: redturtle/[email protected]
Expand Down
44 changes: 44 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Docker build for latest main version
on:
release:
types: [published]

jobs:
build_main:
runs-on: ubuntu-latest
steps:
- name: pull request
if: github.event_name == 'release' && github.event.action == 'published' || github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged == true
uses: actions/checkout@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push Docker images
uses: docker/build-push-action@v3
with:
context: .
tags: redturtletech/io-comune-base:main
pull: true
push: true
cache-from: type=registry,ref=redturtletech/io-comune-base:main
cache-to: type=inline

- name: Deploy to rancher
uses: redturtle/[email protected]
with:
host: ${{ secrets.RANCHER_HOST }}
api-username: ${{ secrets.RANCHER_API_USERNAME }}
api-password: ${{ secrets.RANCHER_API_PASSWORD }}
cluster-id: ${{ secrets.RANCHER_CLUSTER_ID }}
project-id: ${{ secrets.RANCHER_PROJECT_ID }}
namespace: ${{ secrets.RANCHER_NAMESPACE }}
workload: ${{ secrets.RANCHER_WORKLOAD }}
image: redturtletech/io-comune-base:main
slack-hook-url: ${{ secrets.RANCHER_SLACK_HOOK_URL }}
Loading

0 comments on commit e064a32

Please sign in to comment.