Skip to content

Commit

Permalink
Merge branch 'main' into signatures
Browse files Browse the repository at this point in the history
  • Loading branch information
axdotl committed Jul 23, 2021
2 parents 36748db + f7debb5 commit 3fa7f86
Show file tree
Hide file tree
Showing 120 changed files with 12,831 additions and 84 deletions.
Binary file added .DS_Store
Binary file not shown.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @Staffbase/need-for-speed-devs
30 changes: 30 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
name: Bug Report
about: Create a report to help us improve
labels: bug
---

<!-- Please use this template while reporting a bug and provide as much info as possible. -->

### Bug Description

<!-- A description of what the bug is. -->

### Expected Behavior

<!-- A description of what you expected to happen. -->

### How to Reproduce

<!-- A description or list of steps how to reproduce the bug. -->

### Context

<!--- How has this issue affected you? What are you trying to accomplish? -->

### Environment

<!--- Include as many relevant details about the environment you experienced the bug in -->

- Version:
- OS:
19 changes: 19 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
name: 'Feature Request'
about: 'Suggest new features and changes'
labels: enhancement
---

<!--- Provide a general summary of the feature request in the title above -->

### Feature Suggestion

<!--- Tell us how we could improve your experience -->

### Possible Implementation

<!--- Not obligatory, but ideas as to the implementation of the addition or change -->

### Context

<!--- What are you trying to accomplish? -->
22 changes: 22 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
### Type of Change

<!-- Select the type of your PR -->

- [ ] Bugfix
- [ ] Enhancement / new feature
- [ ] Refactoring
- [ ] Documentation

### Description

<!-- Please describe your pull request -->

### Checklist

<!-- Please go through this checklist and make sure all applicable tasks have been done -->

- [ ] Write tests
- [ ] Make sure all tests pass
- [ ] Update documentation
- [ ] Review the [Contributing Guideline](https://github.com/Staffbase/custom-widgets-examples/blob/main/CONTRIBUTING.md) and sign CLA
- [ ] Reference relevant issue(s) and close them after merging
56 changes: 56 additions & 0 deletions .github/workflows/cd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Deploy samples to Netlify
env:
NODE_VERISON: 14
on:
push:
branches:
- main
pull_request:
types: [ labeled, opened ]
# paths:
# - samples/weatherforecast/

jobs:
build-and-deploy:
if: github.event.label.name == 'dev' || github.base_ref == 'main'
runs-on: ubuntu-20.04

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

- name: Use Node JS
uses: actions/setup-node@v2
with:
node-version: ${{ env.NODE_VERSION }}

- name: Install Yarn Dependencies
run: yarn install --cwd samples/weather-forecast --frozen-lockfile

- name: Build widget
run: yarn --cwd samples/weather-forecast build

- name: Prepare Deployment
run: |
mkdir -p samples/deploy/icons
cp samples/netlify.toml samples/deploy/
cp samples/weather-forecast/dist/* samples/deploy/
cp samples/weather-forecast/resources/weather-forecast.svg samples/deploy/icons/
- name: Publish to Production
if: github.base_ref == 'main'
uses: netlify/actions/cli@master
with:
args: deploy --prod --dir=samples/deploy
env:
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}

- name: Publish to DevelopmentPreview
if: github.event.label.name == 'dev'
uses: netlify/actions/cli@master
with:
args: deploy --prod --dir=samples/deploy/
env:
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID_DEV }}
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN_DEV }}
26 changes: 26 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: CI Tests
env:
NODE_VERISON: 14
on:
push:
paths-ignore:
- '**.md'

jobs:
executing-tests:
runs-on: ubuntu-20.04

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

- name: Use Node JS
uses: actions/setup-node@v2
with:
node-version: ${{ env.NODE_VERSION }}

- name: Install Yarn Dependencies
run: yarn install --cwd samples/weather-forecast --frozen-lockfile

- name: Run Tests
run: yarn --cwd samples/weather-forecast test
14 changes: 6 additions & 8 deletions .github/workflows/cla.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,14 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: "CLA Assistant"
if: (github.event.comment.body == 'recheckcla' || github.event.comment.body == 'I have read the CLA Document and I hereby sign the CLA') || github.event_name == 'pull_request'
uses: cla-assistant/[email protected].1-beta
env:
if: (github.event.comment.body == 'recheck' || github.event.comment.body == 'I have read the CLA Document and I hereby sign the CLA') || github.event_name == 'pull_request'
uses: cla-assistant/[email protected].3-beta
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# See: https://github.com/cla-assistant/github-action#6-adding-personal-access-token-as-a-secret
# PERSONAL_ACCESS_TOKEN:
PERSONAL_ACCESS_TOKEN: ${{ secrets.OSS_CONTRIBUTOR_LICENSE_AGREEMENT }}
with:
path-to-signatures: 'signatures/version1/cla.json'
path-to-document: 'https://github.com/Staffbase/template-oss-repository/blob/master/CLA.md'
path-to-document: 'https://github.com/Staffbase/custom-widgets-examples/blob/main/CLA.md'
# branch should not be protected
branch: 'signatures'
# no allowlist currently
# allowlist: user1,user2,bot*
allowlist: Ninerian,m-seidel,cornelius-behrend,boehmmic,FenziRocks,staffbot,dependabot
69 changes: 7 additions & 62 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,68 +1,13 @@
# Staffbase Open Source Repository Template
# Custom Widget Examples

This repository should be used as a template or model for projects we like to publish as Open Source.
This repository holds an example widget as showcase for the Staffbase custom widget development. This example should help developers creating their own custom widget.

Please note this is the instance for projects we want to publish below the **Apache 2.0** license. There might be other permitted licenses in the future.

Please adhere to the [**Staffbase Open Source Policy**](https://mitarbeiterapp.atlassian.net/wiki/spaces/LEGAL/pages/1369178123/Staffbase+Open+Source+Policy). Do not publish anything without following this policy.
## Weather Widget
![weather widget](https://user-images.githubusercontent.com/47413751/122441072-78e4ae80-cf9d-11eb-89a4-dff8855093aa.png)

This repository shows the structure of an compliant OSS project with the following documents and tools:

* [LICENSE](../master/LICENSE) file
* [CONTRIBUTING.md](../master/CONTRIBUTING.md) file (clarifying how to contribute)
* [CLA.md](../master/CLA.md) file (a Contributor License Agreement, see below)
* Every source code file ([example](../master/src/main/your-code-files-here.js)) must start with a license header (see below)
* A [configuration](../master/.github/workflows/cla.yml) for the CLA Assistant Lite

## Source File License Header
Please adjust the block comment syntax to your programming language ;)

Please adjust the year(s) at the copyright statement following [this section at our Open Source Policy](https://mitarbeiterapp.atlassian.net/wiki/spaces/LEGAL/pages/1600422442/Copyright+Statements+in+Staffbase+Code+Files).

```
/*
Copyright 2020, Staffbase GmbH and contributors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
```

## What is an CLA or *Contributor License Agreement*?
- In order to allow other Non-Staffpranos to contribute to our public repositories, those contributors need to sign an agreement to lower the risk for Staffbase to introduce serious legal issues when incorporating outside contributions.

- That's a common process at the Open Source community and you find lots of those agreements at GitHub.

- Staffbase Legal has created our own CLA [which you can find right here](../master/CLA.md).

- To streamline this digital signing process, there are some tools around that integrate with GitHub.

- We're using CLA Assistant and currently experimenting with the *Lite* version, because it uses a local storage (and is not connecting another SaaS solution) of the signatures and runs as a GitHub Action directly below the respective repository.

- This GitHub Action adds a check to every Pull Request and blocks the merging until all contributors have signed the CLA (by commenting a line like "I have read the CLA Document and I hereby sign the CLA" to the PR).


## How to adjust the CLA Assistant Lite?
The central configuration is below the GitHub Action configuration:

[.github/workflows/cla.yml](../master/.github/workflows/cla.yml)

- The signatures are simply stored within a JSON document
- This document gets updated as soon as a contributor signs the CLA
- Since the main (legacy master) branch should be protected, the default branch for those signatures is now *signatures*. Make sure to create this branch initially.
- **Important** You need to set the `PERSONAL_ACCESS_TOKEN` as secret. See https://github.
com/cla-assistant/github-action#6-adding-personal-access-token-as-a-secret
- You can also add whitelisted users, who don't need to sign the CLA. Please do this only with Staffpranos.
- **Important**: Once a Staffprano has left Staffbase, we need to make sure to remove this user from those whitelists (!).
This widget can be used to display the weather at the current time or a fixed date in the future for an individual city. To show the weather the city (optional with country code) needs to be added in the widget configuration.


More information about Staffbase custom widgets can be found here:
[Custom Widget Documentation](https://developers.staffbase.com/guide/customwidget-development)
Binary file added samples/.DS_Store
Binary file not shown.
5 changes: 5 additions & 0 deletions samples/netlify.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# sending status code 200 makes this a rewrite instead of a redirect
[[redirects]]
from = "/*"
to = "/staffbase.weather-forecast.js"
status = 200
19 changes: 19 additions & 0 deletions samples/weather-forecast/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"presets": [
[
"@babel/preset-env",
{
"useBuiltIns": "usage",
"corejs": 3,
"targets": "> 0.25%, not dead, not ie < 11"
}
],
"@babel/preset-react",
"@babel/preset-typescript"
],
"plugins": [
"@babel/plugin-syntax-dynamic-import",
"@babel/plugin-proposal-class-properties",
"@babel/plugin-proposal-object-rest-spread"
]
}
6 changes: 6 additions & 0 deletions samples/weather-forecast/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# don't ever lint node_modules
node_modules
# don't lint build output (make sure it's set to your correct build folder name)
dist
# don't lint nyc coverage output
coverage
14 changes: 14 additions & 0 deletions samples/weather-forecast/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module.exports = {
root: true,
parser: "@typescript-eslint/parser",
plugins: ["@typescript-eslint"],
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:prettier/recommended"
],
rules: {
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": ["error", { argsIgnorePattern: "^_" }],
},
};
18 changes: 18 additions & 0 deletions samples/weather-forecast/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# dependencies
/node_modules
/package-lock.json

# misc
.DS_Store
.env
.env.local
.env.development.local
.env.test.local
.env.production.local

# Dist
/dist

npm-debug.log*
yarn-debug.log*
yarn-error.log*
2 changes: 2 additions & 0 deletions samples/weather-forecast/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
dist
25 changes: 25 additions & 0 deletions samples/weather-forecast/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# staffbase / weather-forecast
## Installation

```bash
$ yarn install
```

## Running the app

| Command | Description |
|---|---|
| `yarn start` | Starts the development server |
| `yarn run build` | Creates the production build |
| `yarn run build:watch` | Creates the production build and watch for changes |
| `yarn run test` | Runs the unit tests |
| `yarn run test:watch` | Runs the unit tests and watches for changes |
| `yarn run type-check` | Checks the codebase on type errors |
| `yarn run type-check:watch` | Checks the codebase on type errors and watches for changes |
| `yarn run lint` | Checks the codebase on style issues |
| `yarn run lint:fix` | Fixes style issues in the codebase |


## Building the form for configuration

This project uses [react-jsonschema-form](https://rjsf-team.github.io/react-jsonschema-form/) for configuring the widget properties. For more information consult their [documentation](https://react-jsonschema-form.readthedocs.io/en/latest/)
3 changes: 3 additions & 0 deletions samples/weather-forecast/__mocks__/fileMock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// __mocks__/fileMock.js

module.exports = 'test-file-stub';
Loading

0 comments on commit 3fa7f86

Please sign in to comment.