|
| 1 | +name: Test and Release |
| 2 | + |
| 3 | +# Run this job on all pushes and pull requests |
| 4 | +# as well as tags with a semantic version |
| 5 | +on: |
| 6 | + push: |
| 7 | + branches: |
| 8 | + - "*" |
| 9 | + tags: |
| 10 | + # normal versions |
| 11 | + - "v[0-9]+.[0-9]+.[0-9]+" |
| 12 | + # pre-releases |
| 13 | + - "v[0-9]+.[0-9]+.[0-9]+-**" |
| 14 | + pull_request: {} |
| 15 | + |
| 16 | +jobs: |
| 17 | + # Performs quick checks before the expensive test runs |
| 18 | + check-and-lint: |
| 19 | + if: contains(github.event.head_commit.message, '[skip ci]') == false |
| 20 | + |
| 21 | + runs-on: ubuntu-latest |
| 22 | + |
| 23 | + strategy: |
| 24 | + matrix: |
| 25 | + node-version: [14.x] |
| 26 | + |
| 27 | + steps: |
| 28 | + - name: Checkout code |
| 29 | + uses: actions/checkout@v2 |
| 30 | + |
| 31 | + - name: Use Node.js ${{ matrix.node-version }} |
| 32 | + uses: actions/setup-node@v1 |
| 33 | + with: |
| 34 | + node-version: ${{ matrix.node-version }} |
| 35 | + |
| 36 | + - name: Install Dependencies |
| 37 | + run: npm ci |
| 38 | + |
| 39 | + - name: Lint source code |
| 40 | + run: npm run lint |
| 41 | + - name: Test package files |
| 42 | + run: npm run test:package |
| 43 | + |
| 44 | + # Runs adapter tests on all supported node versions and OSes |
| 45 | + adapter-tests: |
| 46 | + if: contains(github.event.head_commit.message, '[skip ci]') == false |
| 47 | + |
| 48 | + needs: [check-and-lint] |
| 49 | + |
| 50 | + runs-on: ${{ matrix.os }} |
| 51 | + strategy: |
| 52 | + matrix: |
| 53 | + node-version: [10.x, 12.x, 14.x] |
| 54 | + os: [ubuntu-latest, windows-latest, macos-latest] |
| 55 | + |
| 56 | + steps: |
| 57 | + - name: Checkout code |
| 58 | + uses: actions/checkout@v2 |
| 59 | + |
| 60 | + - name: Use Node.js ${{ matrix.node-version }} |
| 61 | + uses: actions/setup-node@v1 |
| 62 | + with: |
| 63 | + node-version: ${{ matrix.node-version }} |
| 64 | + |
| 65 | + - name: Install Dependencies |
| 66 | + run: npm ci |
| 67 | + |
| 68 | + - name: Run unit tests |
| 69 | + run: npm run test:unit |
| 70 | + |
| 71 | + - name: Run integration tests (unix only) |
| 72 | + if: startsWith(runner.OS, 'windows') == false |
| 73 | + run: DEBUG=testing:* npm run test:integration |
| 74 | + |
| 75 | + - name: Run integration tests (windows only) |
| 76 | + if: startsWith(runner.OS, 'windows') |
| 77 | + run: set DEBUG=testing:* & npm run test:integration |
| 78 | + |
| 79 | +# TODO: To enable automatic npm releases, create a token on npmjs.org |
| 80 | +# Enter this token as a GitHub secret (with name NPM_TOKEN) in the repository options |
| 81 | +# Then uncomment the following block: |
| 82 | + |
| 83 | +# # Deploys the final package to NPM |
| 84 | +# deploy: |
| 85 | +# needs: [adapter-tests] |
| 86 | +# |
| 87 | +# # Trigger this step only when a commit on master is tagged with a version number |
| 88 | +# if: | |
| 89 | +# contains(github.event.head_commit.message, '[skip ci]') == false && |
| 90 | +# github.event_name == 'push' && |
| 91 | +# github.event.base_ref == 'refs/heads/master' && |
| 92 | +# startsWith(github.ref, 'refs/tags/v') |
| 93 | +# |
| 94 | +# runs-on: ubuntu-latest |
| 95 | +# strategy: |
| 96 | +# matrix: |
| 97 | +# node-version: [14.x] |
| 98 | +# |
| 99 | +# steps: |
| 100 | +# - name: Checkout code |
| 101 | +# uses: actions/checkout@v2 |
| 102 | +# |
| 103 | +# - name: Use Node.js ${{ matrix.node-version }} |
| 104 | +# uses: actions/setup-node@v1 |
| 105 | +# with: |
| 106 | +# node-version: ${{ matrix.node-version }} |
| 107 | +# |
| 108 | +# - name: Extract the version and commit body from the tag |
| 109 | +# # The body may be multiline, therefore newlines and % need to be escaped |
| 110 | +# run: | |
| 111 | +# VERSION="${{ github.ref }}" |
| 112 | +# VERSION=${VERSION##*/v} |
| 113 | +# echo "::set-env name=VERSION::$VERSION" |
| 114 | +# BODY=$(git show -s --format=%b) |
| 115 | +# BODY="${BODY//'%'/'%25'}" |
| 116 | +# BODY="${BODY//$'\n'/'%0A'}" |
| 117 | +# BODY="${BODY//$'\r'/'%0D'}" |
| 118 | +# echo "::set-env name=BODY::$BODY" |
| 119 | +# |
| 120 | +# - name: Publish package to npm |
| 121 | +# run: | |
| 122 | +# npm config set //registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }} |
| 123 | +# npm whoami |
| 124 | +# npm publish |
| 125 | +# |
| 126 | +# - name: Create Github Release |
| 127 | +# uses: actions/create-release@v1 |
| 128 | +# env: |
| 129 | +# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 130 | +# with: |
| 131 | +# tag_name: ${{ github.ref }} |
| 132 | +# release_name: Release v${{ env.VERSION }} |
| 133 | +# draft: false |
| 134 | +# # Prerelease versions create prereleases on Github |
| 135 | +# prerelease: ${{ contains(env.VERSION, '-') }} |
| 136 | +# body: ${{ env.BODY }} |
0 commit comments