Skip to content
Open
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
321 changes: 188 additions & 133 deletions .github/workflows/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ on:

jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [14.x]

os: [ubuntu-latest]
node-version: [12.x]
runs-on: ${{ matrix.os }}
timeout-minutes: 15
steps:
- name: Checkout code repository
uses: actions/checkout@v2
Expand Down Expand Up @@ -41,142 +41,197 @@ jobs:
run: pnpm install
- name: Run build
run: pnpm recursive run build
# - name: Run linting
# run: pnpm recursive run lint
# - name: Run unit tests
# run: pnpm recursive run test
release-manual:
# Run release job only on pushes to the main branch. The job depends on completion of the build job.
if: ${{ false }} # github.event_name == 'push' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout code repository
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Setup pnpm
uses: pnpm/action-setup@v2.0.1
with:
version: 6.0.2
run_install: true
- name: Cache pnpm modules
uses: actions/cache@v2
env:
cache-name: cache-pnpm-modules
with:
path: ~/.pnpm-store
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
- name: Use Node.js 14.x
uses: actions/setup-node@v2
with:
node-version: 14.x
- name: Install pnpm modules
run: pnpm install
- name: Run build
run: pnpm recursive run build
- name: Setup npmrc with npmjs.com token
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPMJS_TOKEN }}" > .npmrc
- name: Create changesets versioning and publishing PR
uses: changesets/action@master
with:
version: pnpm ci:version
commit: 'chore: bump versions and publish to npmjs'
title: 'chore: bump versions and publish to npmjs'
publish: pnpm ci:publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
version-auto:
# Run release job only on pushes to the main branch. The job depends on completion of the build job.
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
needs: build
outputs:
changes: ${{ steps.changesetVersion.outputs.changes }} # map step output to job output
steps:
- name: Checkout code repository
uses: actions/checkout@v2
with:
fetch-depth: 0
token: ${{ secrets.ACTIONS_PAT }}
- name: Setup pnpm
uses: pnpm/action-setup@v2.0.1
with:
version: 6.0.2
run_install: true
- name: Cache pnpm modules
uses: actions/cache@v2
env:
cache-name: cache-pnpm-modules
with:
path: ~/.pnpm-store
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
- name: Use Node.js 14.x
uses: actions/setup-node@v2
with:
node-version: 14.x
- name: Install pnpm modules
run: pnpm install
- name: Apply changesets
id: changesetVersion
- name: Run linting
run: pnpm recursive run lint
- name: Run unit tests
run: pnpm recursive run test
- name: Replace sonar test coverage report parts
run: |
echo ::set-output name=changes::$(pnpm ci:version 2>&1 | grep -q 'No unreleased changesets found' && echo 'false' || echo 'true')
git status
- name: Commit and push changes
if: steps.changesetVersion.outputs.changes == 'true'
find . -name 'test-report.xml' -exec sed -i 's+/home/runner/work/learn-github-actions/learn-github-actions+/github/workspace+g' {} \;
- name: Display workspace directory
run: |
git config user.name github-actions
git config user.email github-actions@github.com
git status
git add -A
git status
git commit -m "chore: apply latest changesets" || echo "No changes to commit"
git log --pretty=oneline | head -n 10
git push
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
release-auto:
# Run release job only on pushes to the main branch. The job depends on completion of the build job.
# This job needs to run after the version-auto commit has been merged - so check if that step returns 'false'
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && needs.version-auto.outputs.changes == 'false'
echo $GITHUB_WORKSPACE
cat packages/weather/core/reports/test/unit/test-report.xml
- name: Upload coverage reports
uses: actions/upload-artifact@v2
with:
name: sonar-coverage-reports
path: |
packages/**/reports/**/test-report.xml
retention-days: 1
# - name: Run SonarCloud scan
# if: matrix.os == 'ubuntu-latest' && matrix.node-version == '12.x'
# uses: sonarsource/sonarcloud-github-action@master
# env:
# GITHUB_TOKEN: ${{ secrets.ACCESS_PAT }}
# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

sonar-scan:
name: Run SonarCloud scan
strategy:
matrix:
project_base_dir: [
'packages/weather/core',
'packages/weather/cli'
]
runs-on: ubuntu-latest
needs: version-auto
needs: build
steps:
- name: Checkout code repository
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Setup pnpm
uses: pnpm/action-setup@v2.0.1
with:
version: 6.0.2
run_install: true
- name: Cache pnpm modules
uses: actions/cache@v2
env:
cache-name: cache-pnpm-modules
- name: Download coverage reports
uses: actions/download-artifact@v2
with:
path: ~/.pnpm-store
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
- name: Use Node.js 14.x
uses: actions/setup-node@v2
with:
node-version: 14.x
- name: Install pnpm modules
run: pnpm install
- name: Run build
run: pnpm recursive run build
- name: Setup npmrc with npmjs.com token
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPMJS_TOKEN }}" > .npmrc
- name: 'Publish to npmjs'
uses: changesets/action@master
with:
publish: pnpm ci:publish
name: sonar-coverage-reports
path: packages
- name: Display workspace directory
run: |
echo $GITHUB_WORKSPACE
cat packages/weather/core/reports/test/unit/test-report.xml
- name: Display structure of downloaded artifacts
run: ls -R
- name: Run SonarCloud scan
uses: sonarsource/sonarcloud-github-action@master
with:
projectBaseDir: ${{ matrix.project_base_dir }}
env:
GITHUB_TOKEN: ${{ secrets.ACTIONS_PAT }}
GITHUB_TOKEN: ${{ secrets.ACCESS_PAT }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

# release-manual:
# # Run release job only on pushes to the main branch. The job depends on completion of the build job.
# if: ${{ false }} # github.event_name == 'push' && github.ref == 'refs/heads/main'
# runs-on: ubuntu-latest
# needs: build
# steps:
# - name: Checkout code repository
# uses: actions/checkout@v2
# with:
# fetch-depth: 0
# - name: Setup pnpm
# uses: pnpm/action-setup@v2.0.1
# with:
# version: 6.0.2
# run_install: true
# - name: Cache pnpm modules
# uses: actions/cache@v2
# env:
# cache-name: cache-pnpm-modules
# with:
# path: ~/.pnpm-store
# key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/pnpm-lock.yaml') }}
# restore-keys: |
# ${{ runner.os }}-build-${{ env.cache-name }}-
# - name: Use Node.js 14.x
# uses: actions/setup-node@v2
# with:
# node-version: 14.x
# - name: Install pnpm modules
# run: pnpm install
# - name: Run build
# run: pnpm recursive run build
# - name: Setup npmrc with npmjs.com token
# run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPMJS_TOKEN }}" > .npmrc
# - name: Create changesets versioning and publishing PR
# uses: changesets/action@master
# with:
# version: pnpm ci:version
# commit: 'chore: bump versions and publish to npmjs'
# title: 'chore: bump versions and publish to npmjs'
# publish: pnpm ci:publish
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# version-auto:
# # Run release job only on pushes to the main branch. The job depends on completion of the build job.
# if: github.event_name == 'push' && github.ref == 'refs/heads/main'
# runs-on: ubuntu-latest
# needs: build
# outputs:
# changes: ${{ steps.changesetVersion.outputs.changes }} # map step output to job output
# steps:
# - name: Checkout code repository
# uses: actions/checkout@v2
# with:
# fetch-depth: 0
# token: ${{ secrets.ACTIONS_PAT }}
# - name: Setup pnpm
# uses: pnpm/action-setup@v2.0.1
# with:
# version: 6.0.2
# run_install: true
# - name: Cache pnpm modules
# uses: actions/cache@v2
# env:
# cache-name: cache-pnpm-modules
# with:
# path: ~/.pnpm-store
# key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/pnpm-lock.yaml') }}
# restore-keys: |
# ${{ runner.os }}-build-${{ env.cache-name }}-
# - name: Use Node.js 14.x
# uses: actions/setup-node@v2
# with:
# node-version: 14.x
# - name: Install pnpm modules
# run: pnpm install
# - name: Apply changesets
# id: changesetVersion
# run: |
# echo ::set-output name=changes::$(pnpm ci:version 2>&1 | grep -q 'No unreleased changesets found' && echo 'false' || echo 'true')
# git status
# - name: Commit and push changes
# if: steps.changesetVersion.outputs.changes == 'true'
# run: |
# git config user.name github-actions
# git config user.email github-actions@github.com
# git status
# git add -A
# git status
# git commit -m "chore: apply latest changesets" || echo "No changes to commit"
# git log --pretty=oneline | head -n 10
# git push
# # env:
# # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# release-auto:
# # Run release job only on pushes to the main branch. The job depends on completion of the build job.
# # This job needs to run after the version-auto commit has been merged - so check if that step returns 'false'
# if: github.event_name == 'push' && github.ref == 'refs/heads/main' && needs.version-auto.outputs.changes == 'false'
# runs-on: ubuntu-latest
# needs: version-auto
# steps:
# - name: Checkout code repository
# uses: actions/checkout@v2
# with:
# fetch-depth: 0
# - name: Setup pnpm
# uses: pnpm/action-setup@v2.0.1
# with:
# version: 6.0.2
# run_install: true
# - name: Cache pnpm modules
# uses: actions/cache@v2
# env:
# cache-name: cache-pnpm-modules
# with:
# path: ~/.pnpm-store
# key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/pnpm-lock.yaml') }}
# restore-keys: |
# ${{ runner.os }}-build-${{ env.cache-name }}-
# - name: Use Node.js 14.x
# uses: actions/setup-node@v2
# with:
# node-version: 14.x
# - name: Install pnpm modules
# run: pnpm install
# - name: Run build
# run: pnpm recursive run build
# - name: Setup npmrc with npmjs.com token
# run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPMJS_TOKEN }}" > .npmrc
# - name: 'Publish to npmjs'
# uses: changesets/action@master
# with:
# publish: pnpm ci:publish
# env:
# GITHUB_TOKEN: ${{ secrets.ACTIONS_PAT }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Jest sonar coverage reports
reports

# Logs
*.log
npm-debug.log*
Expand Down
13 changes: 12 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,17 @@
"devDependencies": {
"@changesets/cli": "2.17.0",
"@types/node": "16.3.0",
"typescript": "4.3.5"
"typescript": "4.3.5",
"@types/jest": "26.0.24",
"@typescript-eslint/eslint-plugin": "4.28.2",
"@typescript-eslint/parser": "4.28.2",
"eslint": "7.30.0",
"eslint-config-prettier": "8.3.0",
"eslint-plugin-import": "2.23.4",
"eslint-plugin-prettier": "3.4.0",
"jest": "27.0.6",
"jest-sonar-reporter": "2.0.0",
"prettier": "2.3.2",
"ts-jest": "27.0.3"
}
}
6 changes: 6 additions & 0 deletions packages/weather/cli/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": ["../../../.eslintrc"],
"parserOptions": {
"project": "./tsconfig.json"
}
}
7 changes: 7 additions & 0 deletions packages/weather/cli/dist/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.addTwoNumbers = void 0;
function addTwoNumbers(a, b) {
return a + b;
}
exports.addTwoNumbers = addTwoNumbers;
13 changes: 13 additions & 0 deletions packages/weather/cli/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module.exports = {
transform: {
'^.+\\.tsx?$': 'ts-jest'
},
collectCoverage: true,
collectCoverageFrom: ['src/**/*.{ts}'],
coverageDirectory: 'reports/test/unit/coverage',
testResultsProcessor: 'jest-sonar-reporter',
setupFilesAfterEnv: ['./jest.setup.js'],
testMatch: ['**/?(*.)+(test).ts'],
testPathIgnorePatterns: ['<rootDir>/node_modules/'],
modulePathIgnorePatterns: ['<rootDir>/dist']
};
Loading