Skip to content

Commit

Permalink
GitHub Action updates (trailheadapps#128)
Browse files Browse the repository at this point in the history
  • Loading branch information
muenzpraeger authored Jan 22, 2020
1 parent 96174fa commit 81c2aec
Show file tree
Hide file tree
Showing 4 changed files with 118 additions and 7 deletions.
103 changes: 103 additions & 0 deletions .github/workflows/scratch-org-sfdx-ci-master.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# Unique name for this workflow
name: Salesforce DX (scratch org)

# Definition when the workflow should run
on:
push:
branches:
- master

# Jobs to be executed
jobs:
formatting-and-linting:
runs-on: ubuntu-latest
steps:
# Checkout the code in the pull request
- name: 'Checkout source code'
uses: actions/checkout@v2

# Cache node_modules to speed up the process
- name: Restore node_modules cache
id: cache-npm
uses: actions/cache@v1
with:
path: node_modules
key: npm-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
npm-${{ env.cache-name }}-
npm-
# Install npm dependencies for Prettier and Jest
- name: 'Install npm dependencies'
if: steps.cache-npm.outputs.cache-hit != 'true'
run: npm install

# Prettier formatting
- name: 'Code formatting verification with Prettier'
run: npm run prettier:verify

# ESlint
- name: 'Lint Lightning Web Components'
run: npm run lint:lwc

# Unit tests
- name: 'Unit test Lightning Web Components'
run: npm run test:unit

scratch-org-test:
runs-on: ubuntu-latest
needs: formatting-and-linting
steps:
# Install Salesforce CLI
- name: Install Salesforce CLI
run: |
wget https://developer.salesforce.com/media/salesforce-cli/sfdx-linux-amd64.tar.xz
mkdir sfdx-cli
tar xJf sfdx-linux-amd64.tar.xz -C sfdx-cli --strip-components 1
./sfdx-cli/install
# Checkout the code in the pull request
- name: 'Checkout source code'
uses: actions/checkout@v2

# Store secret for dev hub
- name: 'Populate auth file with DEVHUB_SFDX_URL secret'
shell: bash
run: 'echo ${{ secrets.DEVHUB_SFDX_URL}} > ./DEVHUB_SFDX_URL.txt'

# Authenticate dev hub
- name: 'Authenticate Dev Hub'
run: 'sfdx force:auth:sfdxurl:store -f ./DEVHUB_SFDX_URL.txt -a devhub -d'

# Lint Aura components
- name: 'Lint Aura components'
run: 'sfdx force:lightning:lint force-app/main/default/aura --exit'

# Create scratch org
- name: 'Create scratch org'
run: 'sfdx force:org:create -f config/project-scratch-def.json -a scratch-org -s -d 1'

# Deploy source to scratch org
- name: 'Push source to scratch org'
run: 'sfdx force:source:push'

# Assign permissionset
- name: 'Assign permissionset to default user'
run: 'sfdx force:user:permset:assign -n ebikes'

# Import sample data
- name: 'Import sample data'
run: 'sfdx force:data:tree:import -p ./data/sample-data-plan.json'

# Deploy Community metadata
- name: 'Deploy Community metadata'
run: 'sfdx force:mdapi:deploy--deploydir mdapiDeploy/unpackaged -w 5'

# Run Apex tests in scratch org
- name: 'Run Apex tests'
run: 'sfdx force:apex:test:run -c -r human -d ./tests/apex -w 20'

# Housekeeping
- name: 'Delete scratch org'
if: always()
run: 'sfdx force:org:delete -p -u scratch-org'
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Unique name for this workflow
name: Salesforce DX CI Prerelease (scratch org only)
name: Salesforce DX Prerelease (scratch org)

# Definition when the workflow should run
on:
Expand All @@ -17,7 +17,7 @@ jobs:
steps:
# Checkout the code in the pull request
- name: 'Checkout source code'
uses: actions/checkout@v1
uses: actions/checkout@v2

# Cache node_modules to speed up the process
- name: Restore node_modules cache
Expand Down Expand Up @@ -61,7 +61,7 @@ jobs:
# Checkout the code in the pull request
- name: 'Checkout source code'
uses: actions/checkout@v1
uses: actions/checkout@v2

# Install salesforcedx pre-release plugin
- name: 'Install salesforcedx pre-release plugin'
Expand Down Expand Up @@ -106,4 +106,5 @@ jobs:

# Housekeeping
- name: 'Delete scratch org'
if: always()
run: 'sfdx force:org:delete -p -u scratch-org'
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Unique name for this workflow
name: Salesforce DX CI (scratch org only)
name: Salesforce DX (scratch org)

# Definition when the workflow should run
on:
Expand All @@ -17,7 +17,7 @@ jobs:
steps:
# Checkout the code in the pull request
- name: 'Checkout source code'
uses: actions/checkout@v1
uses: actions/checkout@v2

# Cache node_modules to speed up the process
- name: Restore node_modules cache
Expand Down Expand Up @@ -61,7 +61,7 @@ jobs:
# Checkout the code in the pull request
- name: 'Checkout source code'
uses: actions/checkout@v1
uses: actions/checkout@v2

# Store secret for dev hub
- name: 'Populate auth file with DEVHUB_SFDX_URL secret'
Expand All @@ -80,6 +80,12 @@ jobs:
- name: 'Create scratch org'
run: 'sfdx force:org:create -f config/project-scratch-def.json -a scratch-org -s -d 1'

# Wait for package replication
- name: 'Wait for two min for Communities activation'
uses: maddox/actions/sleep@master
with:
args: 120

# Deploy source to scratch org
- name: 'Push source to scratch org'
run: 'sfdx force:source:push'
Expand All @@ -102,4 +108,5 @@ jobs:

# Housekeeping
- name: 'Delete scratch org'
if: always()
run: 'sfdx force:org:delete -p -u scratch-org'
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# E-Bikes Lightning Web Components Sample Application

[![Github Workflow](<https://github.com/trailheadapps/ebikes-lwc/workflows/Salesforce%20DX%20CI%20(scratch%20org%20only)/badge.svg?branch=master>)](https://github.com/trailheadapps/ebikes-lwc/actions)
[![Github Workflow](<https://github.com/trailheadapps/ebikes-lwc/workflows/Salesforce%20DX%20(scratch%20org)/badge.svg?branch=master>)](https://github.com/trailheadapps/ebikes-lwc/actions?query=workflow%3A%22Salesforce+DX+%28scratch+org%29%22)

![ebikes-logo](ebikes-logo.png)

Expand Down

0 comments on commit 81c2aec

Please sign in to comment.