diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml new file mode 100644 index 0000000..34bce65 --- /dev/null +++ b/.github/workflows/workflow.yml @@ -0,0 +1,113 @@ +name: Test +on: + push: + branches: + - master + pull_request: + branches: [ master ] +jobs: + lint: + name: Lint Code Base + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Lint Code Base + uses: github/super-linter@v4 + env: + VALIDATE_ALL_CODEBASE: false + DEFAULT_BRANCH: master + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + VALIDATE_JSCPD: false # Can not exclude specific file: https://github.com/kucherenko/jscpd/issues/215 + VALIDATE_TYPESCRIPT_STANDARD: false + VALIDATE_MARKDOWN: false + build: + name: Build + needs: lint + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v3 + with: + fetch-depth: 0 + - uses: pnpm/action-setup@v2 + with: + version: latest + run_install: true + - name: Build + run: pnpm run build + - name: Upload build + uses: actions/upload-artifact@v3 + with: + name: build + path: dist + tests: + name: Unit Tests + runs-on: ubuntu-latest + needs: build + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - uses: pnpm/action-setup@v2 + with: + version: latest + run_install: | + - recursive: false + - name: Run Unit Tests + run: pnpm test + - uses: actions/upload-artifact@v3 + with: + name: unittest-coverage + path: coverage/lcov.info + sonarcloud: + name: SonarCloud + runs-on: ubuntu-latest + if: github.event_name == 'push' + needs: + - tests + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis + - uses: actions/download-artifact@v3 + with: + name: unittest-coverage + path: coverage + - name: SonarCloud Scan + uses: SonarSource/sonarcloud-github-action@master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + release: + name: Release + runs-on: ubuntu-latest + if: github.event_name == 'push' + needs: + - build + - sonarcloud + - tests + steps: + - uses: actions/checkout@v3 + - name: Install Node.js + uses: actions/setup-node@v3 + with: + node-version: 18 + - uses: pnpm/action-setup@v2 + with: + version: latest + run_install: | + - recursive: false + - name: Download build + uses: actions/download-artifact@v3 + with: + name: build + path: dist + - run: mkdir -p docs + - run: pnpx semantic-release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 8d91017..0000000 --- a/.travis.yml +++ /dev/null @@ -1,29 +0,0 @@ -language: node_js -os: linux -dist: focal - -cache: - directories: - - node_modules - -install: - - npm i pnpm -g - - pnpm install - -jobs: - include: - - stage: test code - addons: - sonarcloud: - organization: saitho - script: - - pnpm test - - 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then sonar-scanner; fi' # sonar only on non-PRs - - stage: release - if: branch = master - node_js: lts/* - deploy: - provider: script - skip_cleanup: true - script: - - pnpx semantic-release diff --git a/sonar-project.properties b/sonar-project.properties index 779d997..d8cf6b5 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -1,12 +1,12 @@ sonar.organization=saitho -sonar.projectKey=ts-appversion +sonar.projectKey=saitho_ts-appversion # ===================================================== # Meta-data for the project # ===================================================== sonar.links.homepage=https://github.com/saitho/ng-appversion -sonar.links.ci=https://travis-ci.com/saitho/ng-appversion +sonar.links.ci=https://github.com/saitho/ts-appversion/actions sonar.links.scm=https://github.com/saitho/ng-appversion sonar.links.issue=https://github.com/saitho/ng-appversion/issues