|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + branches: [master] |
| 6 | + |
| 7 | +jobs: |
| 8 | + formatting-and-linting: |
| 9 | + runs-on: ubuntu-latest |
| 10 | + steps: |
| 11 | + - name: "Checkout source code" |
| 12 | + uses: actions/checkout@v2 |
| 13 | + |
| 14 | + - uses: actions/cache@v2 |
| 15 | + with: |
| 16 | + path: ~/.npm |
| 17 | + key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} |
| 18 | + restore-keys: | |
| 19 | + ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} |
| 20 | +
|
| 21 | + - name: "Install npm dependencies" |
| 22 | + run: npm install |
| 23 | + |
| 24 | + - name: "Code formatting verification with Prettier" |
| 25 | + run: npm run prettier:verify |
| 26 | + |
| 27 | + - name: Install PMD |
| 28 | + run: wget https://github.com/pmd/pmd/releases/download/pmd_releases%2F6.22.0/pmd-bin-6.22.0.zip && unzip pmd-bin-6.22.0.zip |
| 29 | + |
| 30 | + - name: Execute PMD |
| 31 | + run: pmd-bin-6.22.0/bin/run.sh pmd -minimumpriority 2 -d chain -R apex-ruleset.xml -f text -l apex |
| 32 | + |
| 33 | + ci-build: |
| 34 | + runs-on: ubuntu-latest |
| 35 | + steps: |
| 36 | + - name: Install Salesforce CLI |
| 37 | + run: | |
| 38 | + wget https://developer.salesforce.com/media/salesforce-cli/sfdx-linux-amd64.tar.xz |
| 39 | + mkdir sfdx-cli |
| 40 | + tar xJf sfdx-linux-amd64.tar.xz -C sfdx-cli --strip-components 1 |
| 41 | + ./sfdx-cli/install |
| 42 | +
|
| 43 | + - name: Checkout |
| 44 | + uses: actions/checkout@v2 |
| 45 | + |
| 46 | + - name: "Populate auth file with CI_URL secret" |
| 47 | + shell: bash |
| 48 | + run: "echo ${{ secrets.CI_URL}} > ./CI_URL.txt" |
| 49 | + |
| 50 | + - name: "Authenticate CI Sandbox" |
| 51 | + run: "sfdx force:auth:sfdxurl:store -f ./CI_URL.txt -a ci -d" |
| 52 | + |
| 53 | + - name: 'Create scratch org' |
| 54 | + run: 'sfdx force:org:create -f config/project-scratch-def.json -a scratch-org -s -d 1' |
| 55 | + |
| 56 | + - name: 'Push source to scratch org' |
| 57 | + run: 'sfdx force:source:push' |
| 58 | + |
| 59 | + - name: 'Run Apex tests' |
| 60 | + run: npm run test:coverage |
| 61 | + |
| 62 | + - name: 'Delete scratch org' |
| 63 | + if: always() |
| 64 | + run: 'sfdx force:org:delete -p -u scratch-org' |
0 commit comments