Skip to content

Commit

Permalink
build: improve devops experience (#68)
Browse files Browse the repository at this point in the history
---------

Co-authored-by: Sébastien Colladon <colladonsebastien@gmail.com>
  • Loading branch information
LudoMeurillon and scolladon authored Nov 22, 2024
1 parent 482ef42 commit a76c4a6
Show file tree
Hide file tree
Showing 9 changed files with 559 additions and 259 deletions.
13 changes: 9 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,14 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version: 20
cache: "npm"

- name: Set environment variables
run: |
echo "SF_DISABLE_AUTOUPDATE=true" >> $GITHUB_ENV
Expand All @@ -22,14 +27,14 @@ jobs:
sf org login sfdx-url --sfdx-url-file sfdx_auth --set-default-dev-hub --alias hub
sf config set target-dev-hub=hub --global
- name: Checkout
uses: actions/checkout@v4

- name: Create scratch org
run: sf org create scratch --no-namespace --definition-file config/project-scratch-def.json --alias scratch-org --set-default --duration-days 1

- name: Install npm dependencies
run: npm install

- name: Push source to scratch org
run: sf project deploy start
run: npm run build

- name: Run Apex tests
run: npm run test
Expand Down
13 changes: 9 additions & 4 deletions .github/workflows/create-package-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,24 @@ jobs:
echo "SF_DISABLE_TELEMETRY=true" >> $GITHUB_ENV
echo "SF_PROJECT_AUTOUPDATE_DISABLE_FOR_PACKAGE_VERSION_CREATE=true" >> $GITHUB_ENV
- name: Checkout
uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version: 20
cache: 'npm'

- name: Install sfdx and connect to DevHub
run: |
npm install --global @salesforce/cli@${{ vars.SFDX_VERSION }}
echo ${{ secrets.DEVHUB_URL }} > sfdx_auth
sf org login sfdx-url --sfdx-url-file sfdx_auth --set-default-dev-hub --alias hub
sf config set target-dev-hub=hub --global
- name: Checkout
uses: actions/checkout@v4

- name: Create package version
id: create
run: |
packageId=$(sf force package version create --definition-file config/project-scratch-def.json --package "${{ inputs.packageAlias }}" --branch "${{ inputs.branch }}" --tag ${{ github.sha }} --wait 120 --code-coverage --skip-ancestor-check --installation-key-bypass --json | jq -e -r ".result.SubscriberPackageVersionId")
packageId=$(sf package version create --definition-file config/project-scratch-def.json --package "${{ inputs.packageAlias }}" --branch "${{ inputs.branch }}" --tag ${{ github.sha }} --wait 120 --code-coverage --skip-ancestor-check --installation-key-bypass --json | jq -e -r ".result.SubscriberPackageVersionId")
echo "packageId=$packageId" >> $GITHUB_ENV
echo "packageId=$packageId" >> $GITHUB_OUTPUT
12 changes: 3 additions & 9 deletions .github/workflows/on-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,15 @@ jobs:
formatting-and-linting:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-node@v4
with:
node-version: 20

- name: Checkout source code
uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: actions/cache@v4
- uses: actions/setup-node@v4
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
node-version: 20
cache: 'npm'

- name: Set environment variables
run: |
Expand Down
15 changes: 10 additions & 5 deletions .github/workflows/on-release-published.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,23 @@ jobs:
echo "SF_DISABLE_TELEMETRY=true" >> $GITHUB_ENV
echo "SF_PROJECT_AUTOUPDATE_DISABLE_FOR_PACKAGE_VERSION_CREATE=true" >> $GITHUB_ENV
- name: Checkout
uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version: 20
cache: 'npm'

- name: Install sfdx and connect to DevHub
run: |
npm install --global @salesforce/cli@${{ vars.SFDX_VERSION }}
echo ${{ secrets.DEVHUB_URL }} > sfdx_auth
sf org login sfdx-url --sfdx-url-file sfdx_auth --set-default-dev-hub --alias hub
sf config set target-dev-hub=hub --global
- name: Checkout
uses: actions/checkout@v4

- name: Promote latest main package version
run: sf force package version promote --no-prompt --package ${{ needs.create-package-version.outputs.packageId }}
run: sf package version promote --no-prompt --package ${{ needs.create-package-version.outputs.packageId }}

update-release:
runs-on: ubuntu-latest
Expand All @@ -68,7 +73,7 @@ jobs:
### Unlocked Package installation
- Production [link](https://login.salesforce.com/packaging/installPackage.apexp?p0=$packageId)
- Sandbox [link](https://test.salesforce.com/packaging/installPackage.apexp?p0=$packageId)
- sfdx command: \`sf force package install --package $packageId\`
- sfdx command: \`sf package install --package $packageId\`
EOF
)
echo "links<<EOF" >> $GITHUB_ENV
Expand Down
13 changes: 9 additions & 4 deletions .github/workflows/validate-namespace-compatibility.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,26 @@ jobs:
echo "SF_DISABLE_TELEMETRY=true" >> $GITHUB_ENV
echo "SF_PROJECT_AUTOUPDATE_DISABLE_FOR_PACKAGE_VERSION_CREATE=true" >> $GITHUB_ENV
- name: Checkout
uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version: 20
cache: 'npm'

- name: Install sfdx and connect to DevHub
run: |
npm install --global @salesforce/cli@${{ vars.SFDX_VERSION }}
echo ${{ secrets.DEVHUB_URL }} > sfdx_auth
sf org login sfdx-url --sfdx-url-file sfdx_auth --set-default-dev-hub --alias hub
sf config set target-dev-hub=hub --global
- name: Checkout
uses: actions/checkout@v4

- name: Create scratch org
run: sf org create scratch --definition-file config/project-scratch-def.json --alias scratch-org --set-default --duration-days 1

- name: Check package installation
run: sf force package install --package ${{ inputs.packageId }} --wait 10
run: sf package install --package ${{ inputs.packageId }} --wait 10

- name: Deploy cross namespace tests
run: |
Expand Down
13 changes: 9 additions & 4 deletions .github/workflows/validate-package-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,26 @@ jobs:
echo "SF_DISABLE_TELEMETRY=true" >> $GITHUB_ENV
echo "SF_PROJECT_AUTOUPDATE_DISABLE_FOR_PACKAGE_VERSION_CREATE=true" >> $GITHUB_ENV
- name: Checkout
uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version: 20
cache: 'npm'

- name: Install sfdx and connect to DevHub
run: |
npm install --global @salesforce/cli@${{ vars.SFDX_VERSION }}
echo ${{ secrets.DEVHUB_URL }} > sfdx_auth
sf org login sfdx-url --sfdx-url-file sfdx_auth --set-default-dev-hub --alias hub
sf config set target-dev-hub=hub --global
- name: Checkout
uses: actions/checkout@v4

- name: Create scratch org
run: sf org create scratch --no-namespace --definition-file config/project-scratch-def.json --alias scratch-org --set-default --duration-days 1

- name: Check package installation
run: sf force package install --package ${{ inputs.packageId }} --wait 10
run: sf package install --package ${{ inputs.packageId }} --wait 10

- name: Deploy recipes
run: sf project deploy start --source-dir force-app/recipes
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ yarn-error.log*

# Dependency directories
node_modules/
.wireit/

# Eslint cache
.eslintcache
Expand Down
Loading

0 comments on commit a76c4a6

Please sign in to comment.