diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index 8891e61d..00000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,38 +0,0 @@ -name: CI -on: - pull_request: - branches: - - main - push: - branches: - - main -env: - ACTION_NAME: install-octopus-cli-action -jobs: - build-test: - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [macos-latest, windows-latest, ubuntu-latest] - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 - with: - node-version: 16 - - run: npm ci - - run: npm run all - - name: Install Octopus CLI - uses: ./ - with: - version: latest - - run: octo version - release-please: - name: Release - needs: [build-test] - runs-on: ubuntu-latest - steps: - - uses: google-github-actions/release-please-action@v3 - id: release - with: - package-name: ${{env.ACTION_NAME}} - release-type: node \ No newline at end of file diff --git a/.github/workflows/dist.yml b/.github/workflows/dist.yml new file mode 100644 index 00000000..5df8948b --- /dev/null +++ b/.github/workflows/dist.yml @@ -0,0 +1,32 @@ +on: + push: + branches: + - release-please--** +name: "Build & Push Dist" +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + token: ${{ secrets.INTEGRATIONS_FNM_BOT_TOKEN }} + - name: install + run: npm ci + - name: build + run: npm run build + - name: update README + run: |- + MAJOR_VERSION=$(cat package.json \ + | grep version \ + | head -1 \ + | awk -F: '{ print $2 }' \ + | sed 's/[", ]//g' \ + | awk -F. '{ print $1 }') + sed -i "s/\(uses: OctopusDeploy\/install-octopus-cli-action@\).*/\1v${MAJOR_VERSION}/g" README.md + - name: commit + run: |- + git config --global user.name "team-integrations-fnm-bot" + git config user.email 'integrationsfnmbot@octopus.com' + git add README.md + git add dist/ + git diff-index --quiet HEAD || (git commit -m "chore: build dist and update README" && git push origin) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml deleted file mode 100644 index e03a6deb..00000000 --- a/.github/workflows/publish.yml +++ /dev/null @@ -1,19 +0,0 @@ -name: Publish -on: - release: - types: [published, edited] -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - with: - ref: ${{ github.event.release.tag_name }} - - uses: actions/setup-node@v3 - with: - node-version: 16 - - run: npm ci - - run: npm run build - - uses: JasonEtco/build-and-tag-action@v2 - env: - GITHUB_TOKEN: ${{ github.token }} \ No newline at end of file diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml new file mode 100644 index 00000000..d931e357 --- /dev/null +++ b/.github/workflows/release-please.yml @@ -0,0 +1,44 @@ +on: + push: + branches: + - main +name: release-please +env: + ACTION_NAME: install-octopus-cli-action +jobs: + release-please-release: + runs-on: ubuntu-latest + steps: + - uses: google-github-actions/release-please-action@v3 + id: release + with: + package-name: ${{env.ACTION_NAME}} + release-type: node + token: ${{ github.token }} + command: github-release + - uses: actions/checkout@v3 + - name: tag major and minor versions + if: ${{ steps.release.outputs.release_created }} + run: | + git config user.name github-actions + git config user.email github-actions@github.com + git tag -d v${{ steps.release.outputs.major }} || true + git tag -d v${{ steps.release.outputs.major }}.${{ steps.release.outputs.minor }} || true + git push origin :v${{ steps.release.outputs.major }} || true + git push origin :v${{ steps.release.outputs.major }}.${{ steps.release.outputs.minor }} || true + git tag -a v${{ steps.release.outputs.major }} -m "Release v${{ steps.release.outputs.major }}" + git tag -a v${{ steps.release.outputs.major }}.${{ steps.release.outputs.minor }} -m "Release v${{ steps.release.outputs.major }}.${{ steps.release.outputs.minor }}" + git push origin v${{ steps.release.outputs.major }} + git push origin v${{ steps.release.outputs.major }}.${{ steps.release.outputs.minor }} + release-please-pr: + runs-on: ubuntu-latest + needs: + - release-please-release + steps: + - id: release-pr + uses: google-github-actions/release-please-action@v3 + with: + token: ${{ secrets.INTEGRATIONS_FNM_BOT_TOKEN }} + release-type: node + package-name: ${{env.ACTION_NAME}} + command: release-pr diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8ddf3a7c..20514678 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,21 +1,37 @@ name: 'build-test' on: - pull_request: push: - + schedule: + # Daily 5am australian/brisbane time (7pm UTC) + - cron: '0 19 * * *' jobs: test: - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [macos-latest, windows-latest, ubuntu-latest] + runs-on: ubuntu-latest + # https://github.com/dorny/test-reporter/issues/168 + permissions: + statuses: write + checks: write + steps: - - name: Checkout 🛎️ - uses: actions/checkout@v2 - - run: npm install - - run: npm run all + - uses: actions/checkout@v3 + + - name: Install package dependencies + run: npm install + + - name: Compile and run tests + run: npm run all + + - name: Test Report + uses: dorny/test-reporter@v1 + if: success() || failure() + with: + name: JEST Tests + path: 'reports/jest-*.xml' + reporter: jest-junit + - name: Install Octopus CLI uses: ./ with: version: latest - - run: octo version \ No newline at end of file + + - run: octo version diff --git a/.gitignore b/.gitignore index 64919b16..69fd80c9 100644 --- a/.gitignore +++ b/.gitignore @@ -101,4 +101,5 @@ lib/**/* # ignore test artifacts *.pdb octo -out \ No newline at end of file +out +reports/ \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 83c5bdb4..dcb95e2f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -27,6 +27,7 @@ "eslint-plugin-jest": "^26.2.2", "jest": "^28.1.0", "jest-circus": "^28.1.0", + "jest-junit": "^14.0.0", "js-yaml": "^4.1.0", "prettier": "2.6.2", "tmp": "^0.2.1", @@ -3362,6 +3363,21 @@ "fsevents": "^2.3.2" } }, + "node_modules/jest-junit": { + "version": "14.0.0", + "resolved": "https://registry.npmjs.org/jest-junit/-/jest-junit-14.0.0.tgz", + "integrity": "sha512-kALvBDegstTROfDGXH71UGD7k5g7593Y1wuX1wpWT+QTYcBbmtuGOA8UlAt56zo/B2eMIOcaOVEON3j0VXVa4g==", + "dev": true, + "dependencies": { + "mkdirp": "^1.0.4", + "strip-ansi": "^6.0.1", + "uuid": "^8.3.2", + "xml": "^1.0.1" + }, + "engines": { + "node": ">=10.12.0" + } + }, "node_modules/jest-leak-detector": { "version": "28.1.0", "resolved": "https://registry.npmjs.org/jest-leak-detector/-/jest-leak-detector-28.1.0.tgz", @@ -4100,6 +4116,18 @@ "node": "*" } }, + "node_modules/mkdirp": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz", + "integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==", + "dev": true, + "bin": { + "mkdirp": "bin/cmd.js" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/ms": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", @@ -5084,6 +5112,12 @@ "node": "^12.13.0 || ^14.15.0 || >=16" } }, + "node_modules/xml": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/xml/-/xml-1.0.1.tgz", + "integrity": "sha512-huCv9IH9Tcf95zuYCsQraZtWnJvBtLVE0QHMOs8bWyZAFZNDcYjsPq1nEx8jKA9y+Beo9v+7OBPRisQTjinQMw==", + "dev": true + }, "node_modules/y18n": { "version": "5.0.8", "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", @@ -7642,6 +7676,18 @@ "walker": "^1.0.7" } }, + "jest-junit": { + "version": "14.0.0", + "resolved": "https://registry.npmjs.org/jest-junit/-/jest-junit-14.0.0.tgz", + "integrity": "sha512-kALvBDegstTROfDGXH71UGD7k5g7593Y1wuX1wpWT+QTYcBbmtuGOA8UlAt56zo/B2eMIOcaOVEON3j0VXVa4g==", + "dev": true, + "requires": { + "mkdirp": "^1.0.4", + "strip-ansi": "^6.0.1", + "uuid": "^8.3.2", + "xml": "^1.0.1" + } + }, "jest-leak-detector": { "version": "28.1.0", "resolved": "https://registry.npmjs.org/jest-leak-detector/-/jest-leak-detector-28.1.0.tgz", @@ -8218,6 +8264,12 @@ "brace-expansion": "^1.1.7" } }, + "mkdirp": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz", + "integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==", + "dev": true + }, "ms": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", @@ -8901,6 +8953,12 @@ "signal-exit": "^3.0.7" } }, + "xml": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/xml/-/xml-1.0.1.tgz", + "integrity": "sha512-huCv9IH9Tcf95zuYCsQraZtWnJvBtLVE0QHMOs8bWyZAFZNDcYjsPq1nEx8jKA9y+Beo9v+7OBPRisQTjinQMw==", + "dev": true + }, "y18n": { "version": "5.0.8", "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", diff --git a/package.json b/package.json index 086fc712..db21da68 100644 --- a/package.json +++ b/package.json @@ -23,6 +23,7 @@ "eslint-plugin-jest": "^26.2.2", "jest": "^28.1.0", "jest-circus": "^28.1.0", + "jest-junit": "^14.0.0", "js-yaml": "^4.1.0", "prettier": "2.6.2", "tmp": "^0.2.1", @@ -51,6 +52,15 @@ }, "verbose": true }, + "jest-junit": { + "outputDirectory": "reports", + "outputName": "jest-junit.xml", + "ancestorSeperator": " > ", + "uniqueOutputName": "false", + "suiteNameTemplate": "{filepath}", + "classNameTemplate": "{classname}", + "titleTemplate": "{title}" + }, "keywords": [ "cli", "deployment", @@ -70,8 +80,8 @@ "format": "prettier --write **/*.ts", "format-check": "prettier --check **/*.ts", "prebuild": "eslint src/**/*.ts", - "postbuild": "ncc build -o dist", - "test": "jest --passWithNoTests" + "postbuild": "ncc build out/main.js -o dist", + "test": "jest --ci --reporters=default --reporters=jest-junit --passWithNoTests" }, "version": "1.3.0" } \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index 00173bb3..07172464 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,7 +2,7 @@ "compilerOptions": { "target": "es6", "module": "commonjs", - "outDir": "./dist", + "outDir": "./out", "rootDir": "./src", "strict": true, "noImplicitAny": true,