Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: from jenkins to github action #626

Merged
merged 1 commit into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .commitlintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": ["@commitlint/config-conventional"]
}
3 changes: 3 additions & 0 deletions .githooks/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env sh

npx --no -- commitlint --edit
46 changes: 46 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: 'Build'
on:
push:
branches:
- master
hsablonniere marked this conversation as resolved.
Show resolved Hide resolved
pull_request:
branches:
- master
jobs:
build:
name: 'Build'
hsablonniere marked this conversation as resolved.
Show resolved Hide resolved
runs-on: ubuntu-latest

steps:
- name: '[Prepare] Checkout'
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: '[Prepare] Setup Node.js'
uses: actions/setup-node@v3
with:
node-version-file: 'package.json'
cache: 'npm'
- name: '[Prepare] Install dependencies'
run: npm ci

- name: '[Code quality] Check commit message'
if: github.event_name == 'pull_request'
run: npx commitlint --from ${{ github.event.pull_request.base.sha }} --to ${{ github.event.pull_request.head.sha }} --verbose

# - name: '[Code quality] Check ESLint'
# run: npm run lint
pdesoyres-cc marked this conversation as resolved.
Show resolved Hide resolved

- name: '[Build] [Prepare] Setup ruby'
uses: ruby/setup-ruby@v1
with:
ruby-version: '2.7'
bundler-cache: true
- name: '[Build] [Prepare] Install fpm'
run: gem install fpm
- name: '[Build] [Run] Build'
run: node scripts/job-build.js 0.0.0 --latest --bundle
env:
RPM_GPG_PRIVATE_KEY: ${{ secrets.RPM_GPG_PRIVATE_KEY }}
RPM_GPG_NAME: 'Clever Cloud Nexus (rpm)'
RPM_GPG_PASS: ${{ secrets.RPM_GPG_PASSPHRASE }}
110 changes: 110 additions & 0 deletions .github/workflows/preview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
name: 'Preview'
on:
pull_request:
types:
- synchronize
- opened
- closed

env:
BRANCH: ${{ github.event.pull_request.head.ref }}
CC_CLEVER_TOOLS_PREVIEWS_CELLAR_KEY_ID: ${{ secrets.CC_CLEVER_TOOLS_PREVIEWS_CELLAR_KEY_ID }}
CC_CLEVER_TOOLS_PREVIEWS_CELLAR_SECRET_KEY: ${{ secrets.CC_CLEVER_TOOLS_PREVIEWS_CELLAR_SECRET_KEY }}

jobs:
wait_for_build:
name: 'Wait for build to succeed'
if: |
(github.event.action == 'synchronize' || github.event.action == 'opened')
&& github.event.repository.fork == false
&& !startsWith(github.event.pull_request.head.ref, 'release-please--')
runs-on: ubuntu-latest
steps:
- name: 'Wait for build to succeed'
uses: lewagon/[email protected]
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
check-name: Build
ref: ${{ github.event.pull_request.head.sha }}
allowed-conclusions: success
publish:
name: 'Publish Preview'
needs: wait_for_build
runs-on: ubuntu-latest
steps:
- name: '[Prepare] Checkout'
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: '[Prepare] Setup Node.js'
uses: actions/setup-node@v3
with:
node-version-file: 'package.json'
cache: 'npm'
- name: '[Prepare] Install dependencies'
run: npm ci
- name: '[Prepare] Check if a preview already exists'
id: check_preview
run: |
if node scripts/job-preview.js get ${BRANCH} > /dev/null 2>&1; then
echo "exists=yes" >> $GITHUB_OUTPUT
else
echo "exists=no" >> $GITHUB_OUTPUT
fi

- name: '[Run] Build preview'
run: node scripts/job-preview.js build ${BRANCH}
pdesoyres-cc marked this conversation as resolved.
Show resolved Hide resolved
- name: '[Run] Publish preview'
run: node scripts/job-preview.js publish ${BRANCH}
pdesoyres-cc marked this conversation as resolved.
Show resolved Hide resolved

- name: '[Finalize] Get preview links'
if: steps.check_preview.outputs.exists == 'no'
id: get_preview_links
run: |
PREVIEW_LINKS=$(node scripts/job-preview.js links $BRANCH | sed -z 's/\n/\\n/g'; echo)
echo "PREVIEW_LINKS=${PREVIEW_LINKS::-2}" >> $GITHUB_ENV
- name: '[Finalize] Add comment'
if: steps.check_preview.outputs.exists == 'no'
uses: actions/github-script@v6
with:
script: |
const links = "${{ env.PREVIEW_LINKS }}";
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: `🔎 A preview has been automatically published:\n\n${links}\n\n\n_This preview will be deleted once this PR is closed._`
});
delete:
if: |
github.event.action == 'closed'
&& github.event.repository.fork == false
&& !startsWith(github.event.pull_request.head.ref, 'release-please--')
name: 'Delete Preview'
runs-on: ubuntu-latest
steps:
- name: '[Prepare] Checkout'
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: '[Prepare] Setup Node.js'
uses: actions/setup-node@v3
with:
node-version-file: 'package.json'
cache: 'npm'
- name: '[Prepare] Install dependencies'
run: npm ci

- name: '[Run] Delete preview'
run: node scripts/job-preview.js delete ${BRANCH}

- name: '[Finalize] Add comment'
uses: actions/github-script@v6
with:
script: |
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: `🔎 The preview has been automatically deleted.`
});
59 changes: 59 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: 'Publish'
on:
push:
tags:
- '[0-9]+.[0-9]+.[0-9]+'

env:
VERSION: ${{ github.ref_name }}
CC_CLEVER_TOOLS_RELEASES_CELLAR_KEY_ID: ${{ secrets.CC_CLEVER_TOOLS_RELEASES_CELLAR_KEY_ID }}
CC_CLEVER_TOOLS_RELEASES_CELLAR_SECRET_KEY: ${{ secrets.CC_CLEVER_TOOLS_RELEASES_CELLAR_SECRET_KEY }}
RPM_GPG_PRIVATE_KEY: ${{ secrets.RPM_GPG_PRIVATE_KEY }}
RPM_GPG_NAME: 'Clever Cloud Nexus (rpm)'
RPM_GPG_PASS: ${{ secrets.RPM_GPG_PASSPHRASE }}
NEXUS_USER: ${{ secrets.NEXUS_USER }}
NEXUS_PASSWORD: ${{ secrets.NEXUS_PASSWORD }}
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

jobs:
publish_cellar:
name: 'Publish'
runs-on: ubuntu-latest
steps:
- name: '[Prepare] Checkout'
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: '[Prepare] Setup Node.js'
uses: actions/setup-node@v3
with:
node-version-file: 'package.json'
cache: 'npm'
- name: '[Prepare] Install dependencies'
run: npm ci
- name: '[Prepare] Setup ruby'
uses: ruby/setup-ruby@v1
with:
ruby-version: '2.7'
bundler-cache: true
- name: '[Prepare] Install fpm'
run: gem install fpm
- name: '[Prepare] Setup ssh-agent'
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}

- name: '[Build] version ${{ env.VERSION }}'
run: node scripts/job-build.js "${VERSION}" --latest --bundle

- name: '[Publish] version ${{ env.VERSION }}'
run: node scripts/job-publish.js "${VERSION}"

- name: '[Publish] Upload artifacts to GitHub Release'
shell: bash
run: |
gh release upload "${VERSION}" $(find build/${{ github.ref_name }}/archive -maxdepth 1 -type f -name "*$VERSION*" -print)
gh release upload "${VERSION}" $(find build/${{ github.ref_name }}/bundle -maxdepth 1 -type f -print)
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
17 changes: 17 additions & 0 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: 'release-please'
on:
push:
branches:
- master
- 'hotfix/**'
jobs:
release-please:
runs-on: ubuntu-latest
steps:
- uses: google-github-actions/release-please-action@v3
with:
token: ${{ secrets.CI_TOKEN }}
release-type: node
include-v-in-tag: false
default-branch: ${{ github.ref_name }}
changelog-types: '[{"type": "feat", "section": "🚀 Features"}, {"type": "fix", "section": "🐛 Bug Fixes"}, {"type": "perf", "section": "💪 Performance Improvements"}, {"type": "deps", "section": "🗃️ Dependencies", "hidden": true}, {"type": "revert", "section": "↩ Reverts"}, {"type": "docs", "section": "📖 Documentation", "hidden": true}, {"type": "style", "section": "🎨 Styles", "hidden": true}, {"type": "chore", "section": "🧹 Miscellaneous Chores", "hidden": true}, {"type": "refactor", "section": "🛠 Code Refactoring", "hidden": true}, {"type": "test", "section": "🔬 Tests", "hidden": true}, {"type": "build", "section": "🏗️ Build System", "hidden": true}, {"type": "ci", "section": "🤖 Continuous Integration", "hidden": true}]'
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ node_modules/
spec/empty-repo
spec/application.instance-types.js
.clever.json
releases/
build/
.idea/
.s3cfg*
*.gpg.key
Expand Down
1 change: 0 additions & 1 deletion .npmrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
tag-version-prefix = ""
message = "Upgrade to %s"
preid = "beta"
40 changes: 40 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# How to contribute?

## We use ESLint

We use [ESLint](https://eslint.org/) to enforce JS coding style and spot linting errors ASAP.
Our configuration is based on [standardJS](https://standardjs.com/) + some small tweaks (see `.eslintrc.js`).

You can run the lint check with:

```shell
npm run lint
```

You can run the lint check (with autofix) with:

```shell
npm run lint:fix
```

## We have precise rules for commit message format

Commit messages must respect [conventional commit](https://www.conventionalcommits.org).

Possible types are `fix:`, `feat:`, `build:`, `chore:`, `ci:`, `docs:`, `style:`, `refactor:`, `perf:`, `test:`.

The scope should be the name of the command affected.
If many commands are affected, consider the following options:
* split into multiple commits
* avoid specifying any scope and add some details instead. However, you must understand that details won't be dumped into the CHANGELOG.

If none of these options suits your need, you can follow [this how-to](https://github.com/googleapis/release-please#what-if-my-pr-contains-multiple-fixes-or-features) that will let you generate multiple CHANGELOG entries with one single commit.

To help you respect the rules, you should install a commit linter with the following command:

```shell
cd ${PATH_TO_THE_REPOSITORY_ROOT}
git config core.hooksPath '.githooks'
```

You must understand that nothing will be dumped into the CHANGELOG if you don't respect these rules.
Loading
Loading