Skip to content

Commit d78dff0

Browse files
authored
[patch] dev experience / gha updates (#1080)
# Pull Request Template ## Description - Removes a bunch of extraneous ghas and files - Creates a single gha that runs tests, and deploys to staging if you merged to master. Tested by commenting out the if statements - makes startDev.js actually work - removes all references to the dev/ directory. Just use the dist/ - makes example.html actually get rendered properly Fixes # (issue) ## Type of change Please delete options that are not relevant. - [ ] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] This change requires a documentation update ## How Has This Been Tested? Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration - [ ] Unit test - [ ] Integration test ## JS Budget Check Please mention the size in kb before abd after this PR | Files | Before | After | | ----------- | ----------- | ----------- | | dist/build.js. | | | | dist/build.min.js| | | ## Checklist: - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [ ] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] Any dependent changes have been merged and published in downstream modules - [ ] I have checked my code and corrected any misspellings ## Mentions: List the person or team responsible for reviewing proposed changes. cc @BranchMetrics/saas-sdk-devs for visibility.
1 parent fa7fed4 commit d78dff0

20 files changed

+221
-680
lines changed

.github/workflows/build-push.yml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: Build and Push
2+
on: push
3+
4+
env:
5+
NODE_VERSION: 18
6+
JAVA_VERSION: 11
7+
JAVA_DISTRIBUTION: 'adopt'
8+
9+
jobs:
10+
build-push:
11+
name: run tests, build and push
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
16+
- name: Install Node ${{ env.NODE_VERSION }}
17+
uses: actions/setup-node@v3
18+
with:
19+
node-version: ${{ env.NODE_VERSION }}
20+
cache: 'npm'
21+
22+
- name: Set up JDK 11
23+
uses: actions/setup-java@v4
24+
with:
25+
java-version: ${{ env.JAVA_VERSION }}
26+
distribution: ${{ env.JAVA_DISTRIBUTION }}
27+
28+
- name: Install dependencies
29+
run: npm run ci
30+
31+
- name: Lint tests
32+
run: npm run lint
33+
34+
- name: Run tests
35+
run: npm run test-report
36+
37+
- name: Test Report
38+
uses: dorny/test-reporter@v1
39+
if: always()
40+
with:
41+
name: Unit Tests
42+
fail-on-error: true,
43+
path: test-results.json # Path to test results
44+
reporter: mocha-json # Format of test results
45+
46+
- name: Publish Test Results
47+
uses: EnricoMi/publish-unit-test-result-action@v2
48+
id: test-results
49+
if: always()
50+
with:
51+
files: "test-results.json"
52+
53+
- name: Run coverage
54+
run: npm run cover
55+
56+
- name: upload codecov
57+
uses: codecov/codecov-action@v4
58+
59+
- name: Check whether we will be able to make the release
60+
run: make release
61+
62+
- name: AWS, credentials setup
63+
if: ${{ github.ref == 'refs/heads/master' }}
64+
uses: aws-actions/configure-aws-credentials@v4
65+
with:
66+
aws-region: us-west-1
67+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
68+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
69+
70+
- name: Deploy updated builds to staging
71+
if: ${{ github.ref == 'refs/heads/master' }}
72+
id: build
73+
run: |
74+
./deployment/deploy-qa.sh

.github/workflows/deploy-qa.yml

Lines changed: 0 additions & 93 deletions
This file was deleted.

.github/workflows/gate-keep.yml

Lines changed: 0 additions & 94 deletions
This file was deleted.

.github/workflows/test.yml

Lines changed: 0 additions & 54 deletions
This file was deleted.

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,6 @@ dev
3737
test-results.json
3838
.idea/
3939
.direnv/
40+
dev.config
41+
dev.html
42+
example.html

Makefile

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -31,24 +31,13 @@ ONPAGE_RELEASE=$(subst ",\",$(shell perl -pe 'BEGIN{$$sub="https://cdn.branch.io
3131
ONPAGE_DEV=$(subst ",\",$(shell perl -pe 'BEGIN{$$sub="build.js"};s\#SCRIPT_URL_HERE\#$$sub\#' src/onpage.js | $(CLOSURE_COMPILER) | node transform.js branch_sdk))
3232
ONPAGE_TEST=$(subst ",\",$(shell perl -pe 'BEGIN{$$sub="../dist/build.js"};s\#SCRIPT_URL_HERE\#$$sub\#' src/onpage.js | $(CLOSURE_COMPILER) | node transform.js branch_sdk))
3333

34-
# Check if the target being executed is "dev" and set COMPILER_DEV_ARGS if API_ENDPOINT argument has value
35-
$(info Building dev...)
36-
ifeq ($(MAKECMDGOALS),dev)
37-
ifneq ($(API_ENDPOINT),)
38-
COMPILER_DEV_ARGS := --define='DEFAULT_API_ENDPOINT=$(API_ENDPOINT)'
39-
endif
40-
endif
41-
4234
.PHONY: clean
4335

44-
all: dist/build.min.js dist/build.js example.html test/branch-deps.js test/integration-test.html
36+
all: dist/build.min.js dist/build.js test/branch-deps.js test/integration-test.html
4537
clean:
46-
rm -f dist/** docs/web/3_branch_web.md example.html test/branch-deps.js dist/build.min.js.gz test/integration-test.html
38+
rm -f dist/** docs/web/3_branch_web.md test/branch-deps.js dist/build.min.js.gz test/integration-test.html
4739
release: clean all dist/build.min.js.gz
4840
@echo "released"
49-
dev-clean:
50-
rm -rf dev/*
51-
dev: dev-clean dev-build example.html
5241

5342
test/branch-deps.js: $(SOURCES)
5443
npx closure-make-deps \
@@ -71,21 +60,6 @@ dist/build.min.js.gz: dist/build.min.js
7160
mkdir -p dist && \
7261
gzip -c dist/build.min.js > dist/build.min.js.gz
7362

74-
dev-build: $(SOURCES) $(EXTERN)
75-
mkdir -p dev && \
76-
$(CLOSURE_COMPILER) $(COMPILER_ARGS) $(COMPILER_DEBUG_ARGS) $(COMPILER_DEV_ARGS) > dev/build.js
77-
78-
example.html: src/web/example.template.html
79-
ifeq ($(MAKECMDGOALS), release)
80-
perl -pe 'BEGIN{$$a="$(ONPAGE_RELEASE)"}; s#// INSERT INIT CODE#$$a#' src/web/example.template.html > example.html
81-
else ifeq ($(MAKECMDGOALS),dev)
82-
perl -pe 'BEGIN{$$b="$(KEY_VALUE)"}; s#key_place_holder#$$b#' src/web/example.template.html > dev/example.template.html
83-
perl -pe 'BEGIN{$$a="$(ONPAGE_DEV)"}; s#// INSERT INIT CODE#$$a#' dev/example.template.html > dev/example.html
84-
rm -rf dev/example.template.html
85-
else
86-
perl -pe 'BEGIN{$$a="$(ONPAGE_DEV)"}; s#// INSERT INIT CODE#$$a#' src/web/example.template.html > example.html
87-
endif
88-
8963
# Documentation
9064

9165
docs/web/3_branch_web.md: $(SOURCES)

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,8 @@ for full details.
2222
- [Testing]
2323
- [Troubleshooting]
2424
- [Web Full Reference]
25+
26+
# Running locally
27+
```sh
28+
node startDev.js
29+
```

0 commit comments

Comments
 (0)