Skip to content

Commit

Permalink
[patch] dev experience / gha updates (#1080)
Browse files Browse the repository at this point in the history
# 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.
  • Loading branch information
bredmond5 authored Nov 6, 2024
1 parent fa7fed4 commit d78dff0
Show file tree
Hide file tree
Showing 20 changed files with 221 additions and 680 deletions.
74 changes: 74 additions & 0 deletions .github/workflows/build-push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: Build and Push
on: push

env:
NODE_VERSION: 18
JAVA_VERSION: 11
JAVA_DISTRIBUTION: 'adopt'

jobs:
build-push:
name: run tests, build and push
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install Node ${{ env.NODE_VERSION }}
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'

- name: Set up JDK 11
uses: actions/setup-java@v4
with:
java-version: ${{ env.JAVA_VERSION }}
distribution: ${{ env.JAVA_DISTRIBUTION }}

- name: Install dependencies
run: npm run ci

- name: Lint tests
run: npm run lint

- name: Run tests
run: npm run test-report

- name: Test Report
uses: dorny/test-reporter@v1
if: always()
with:
name: Unit Tests
fail-on-error: true,
path: test-results.json # Path to test results
reporter: mocha-json # Format of test results

- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action@v2
id: test-results
if: always()
with:
files: "test-results.json"

- name: Run coverage
run: npm run cover

- name: upload codecov
uses: codecov/codecov-action@v4

- name: Check whether we will be able to make the release
run: make release

- name: AWS, credentials setup
if: ${{ github.ref == 'refs/heads/master' }}
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: us-west-1
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}

- name: Deploy updated builds to staging
if: ${{ github.ref == 'refs/heads/master' }}
id: build
run: |
./deployment/deploy-qa.sh
93 changes: 0 additions & 93 deletions .github/workflows/deploy-qa.yml

This file was deleted.

94 changes: 0 additions & 94 deletions .github/workflows/gate-keep.yml

This file was deleted.

54 changes: 0 additions & 54 deletions .github/workflows/test.yml

This file was deleted.

3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,6 @@ dev
test-results.json
.idea/
.direnv/
dev.config
dev.html
example.html
30 changes: 2 additions & 28 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,24 +31,13 @@ ONPAGE_RELEASE=$(subst ",\",$(shell perl -pe 'BEGIN{$$sub="https://cdn.branch.io
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))
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))

# Check if the target being executed is "dev" and set COMPILER_DEV_ARGS if API_ENDPOINT argument has value
$(info Building dev...)
ifeq ($(MAKECMDGOALS),dev)
ifneq ($(API_ENDPOINT),)
COMPILER_DEV_ARGS := --define='DEFAULT_API_ENDPOINT=$(API_ENDPOINT)'
endif
endif

.PHONY: clean

all: dist/build.min.js dist/build.js example.html test/branch-deps.js test/integration-test.html
all: dist/build.min.js dist/build.js test/branch-deps.js test/integration-test.html
clean:
rm -f dist/** docs/web/3_branch_web.md example.html test/branch-deps.js dist/build.min.js.gz test/integration-test.html
rm -f dist/** docs/web/3_branch_web.md test/branch-deps.js dist/build.min.js.gz test/integration-test.html
release: clean all dist/build.min.js.gz
@echo "released"
dev-clean:
rm -rf dev/*
dev: dev-clean dev-build example.html

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

dev-build: $(SOURCES) $(EXTERN)
mkdir -p dev && \
$(CLOSURE_COMPILER) $(COMPILER_ARGS) $(COMPILER_DEBUG_ARGS) $(COMPILER_DEV_ARGS) > dev/build.js

example.html: src/web/example.template.html
ifeq ($(MAKECMDGOALS), release)
perl -pe 'BEGIN{$$a="$(ONPAGE_RELEASE)"}; s#// INSERT INIT CODE#$$a#' src/web/example.template.html > example.html
else ifeq ($(MAKECMDGOALS),dev)
perl -pe 'BEGIN{$$b="$(KEY_VALUE)"}; s#key_place_holder#$$b#' src/web/example.template.html > dev/example.template.html
perl -pe 'BEGIN{$$a="$(ONPAGE_DEV)"}; s#// INSERT INIT CODE#$$a#' dev/example.template.html > dev/example.html
rm -rf dev/example.template.html
else
perl -pe 'BEGIN{$$a="$(ONPAGE_DEV)"}; s#// INSERT INIT CODE#$$a#' src/web/example.template.html > example.html
endif

# Documentation

docs/web/3_branch_web.md: $(SOURCES)
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,8 @@ for full details.
- [Testing]
- [Troubleshooting]
- [Web Full Reference]

# Running locally
```sh
node startDev.js
```
Loading

0 comments on commit d78dff0

Please sign in to comment.