Merge pull request #15 from knaopel/v1.19.0 #35
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Test and release SPFx package | |
on: | |
push: | |
branches: [master] | |
pull_request: | |
workflow_dispatch: | |
concurrency: | |
group: test-build-and-package-${{ github.ref }} | |
env: | |
NODE_VERSION: '18.x' | |
jobs: | |
test: | |
name: Test SPFx with jest | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out git repository | |
uses: actions/checkout@v4 | |
- name: Install Node.js v${{ env.NODE_VERSION }}, and NPM | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ env.NODE_VERSION }} | |
- name: Cache Node modules | |
uses: actions/cache@v4 | |
env: | |
cache-name: cache-node-modules | |
with: | |
path: ~/.npm | |
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-build-${{ env.cache-name }}- | |
${{ runner.os }}-build- | |
${{ runner.os }}- | |
- name: Install dependencies | |
run: npm install | |
- name: Run Unit tests | |
run: | | |
npx jest --coverage --coverageReporters json-summary | |
- name: Jest Coverage Comment | |
uses: MishaKav/[email protected] | |
- name: Test Report | |
uses: phoenix-actions/test-reporting@v8 | |
id: test-report | |
if: success() || failure() | |
with: | |
name: Jest Tests | |
path: jest-*.xml | |
reporter: jest-junit | |
package: | |
name: Package SPFx solution | |
runs-on: ubuntu-latest | |
needs: test | |
outputs: | |
tag-name: ${{ steps.set-tag-name.outputs.tag-name }} | |
if: ${{ github.event_name == 'push' }} | |
steps: | |
- name: Check out git repository | |
uses: actions/checkout@v4 | |
- name: Get Package Properties | |
id: json_properties | |
uses: zoexx/github-action-json-file-properties@release | |
with: | |
file_path: config/package-solution.json | |
prop_path: solution.version | |
- name: Tag Repo | |
run: | | |
git tag -f v${{ steps.json_properties.outputs.value }} | |
git push --tags --force | |
- name: Set Variable value | |
id: set-tag-name | |
run: | | |
echo "tag-name=${{ steps.json_properties.outputs.value }}" >> $GITHUB_OUTPUT | |
- name: Install Node.js v${{ env.NODE_VERSION }}, and NPM | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ env.NODE_VERSION }} | |
- name: Install dependencies | |
run: npm install | |
- name: Bundle solution | |
run: gulp bundle --ship | |
- name: Create sppkg package | |
run: gulp package-solution --ship | |
- name: Publish build artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: sp-pkg | |
path: sharepoint/solution/spfx-react-jest-testing.sppkg | |
if-no-files-found: error | |
release: | |
name: Release sub-job | |
needs: package | |
uses: ./.github/workflows/release.yml | |
# env: | |
# TAG_NAME: ${{needs.package.outputs.TAG_NAME }} | |
with: | |
tag_name: ${{ needs.package.outputs.tag-name }} | |
artifact_name: sp-pkg | |
# name: Release SPFx solution | |
# runs-on: ubuntu-latest | |
# needs: package | |
# steps: | |
# - name: Check out git repository | |
# uses: actions/checkout@v4 | |
# - name: Download published artifact | |
# uses: actions/download-artifact@v4 | |
# with: | |
# name: sp-pkg | |
# - name: Get Package Properties | |
# id: json_properties | |
# uses: zoexx/github-action-json-file-properties@release | |
# with: | |
# file_path: config/package-solution.json | |
# - name: Release SPFx Package | |
# uses: softprops/action-gh-release@v2 | |
# continue-on-error: true | |
# env: | |
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
# with: | |
# files: spfx-react-jest-testing.sppkg | |
# tag_name: ${{ steps.json_properties.solution.version }} | |
# name: Release v${{ steps.json_properties.solution.version }} |