Skip to content

Commit cfebb2f

Browse files
[FSSDK-9348] fix: Publish GH Action & other fun additions (#203)
* Add initial devcontainer spec * Add GitHub Actions ext * Update the nvm version * Update name attrs in Actions * Add missing issue & pr templates * Move publish to own workflow * Add jest & vsc test adapter * Ensure npm is latest * Run all tests 1x but no autoRun * Set up testing via manual workflow dispatch * Trigger from push? * Fix using yarn install I forgot about yarn v npm * Added names to workflow and doing one more dry-run * Remove testing configuration * Fix code review items * Run integration tests only after unit succeeds
1 parent 59fd6d6 commit cfebb2f

9 files changed

+136
-43
lines changed

.devcontainer/devcontainer.json

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
2+
// README at: https://github.com/devcontainers/templates/tree/main/src/javascript-node
3+
{
4+
"name": "React SDK",
5+
6+
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
7+
"image": "mcr.microsoft.com/devcontainers/javascript-node:1-18-bullseye",
8+
9+
// Features to add to the dev container. More info: https://containers.dev/features.
10+
// "features": {},
11+
12+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
13+
// "forwardPorts": [],
14+
15+
// Use 'postCreateCommand' to run commands after the container is created.
16+
"postCreateCommand": "npm install -g npm && yarn install",
17+
18+
// Configure tool-specific properties.
19+
"customizations": {
20+
"vscode": {
21+
"extensions": [
22+
"dbaeumer.vscode-eslint",
23+
"eamodio.gitlens",
24+
"esbenp.prettier-vscode",
25+
"Gruntfuggly.todo-tree",
26+
"github.vscode-github-actions",
27+
"Orta.vscode-jest",
28+
"ms-vscode.test-adapter-converter"
29+
]
30+
}
31+
}
32+
33+
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
34+
// "remoteUser": "root"
35+
}

.github/issue_template.md

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<!--
2+
Thanks for filing in issue! Are you proposing an enhancement or reporting a bug?
3+
4+
If proposing an enhancement, please describe your use case in as much detail as you think is needed to convey the value of the enhancement.
5+
-->
6+
## How would the enhancement work?
7+
8+
## When would the enhancement be useful?
9+
10+
<!--
11+
If reporting a bug, please include the following info:
12+
-->
13+
14+
## What I wanted to do
15+
16+
## What I expected to happen
17+
18+
## What actually happened
19+
20+
## Steps to reproduce
21+
Link to repository that can reproduce the issue: <link>
22+
23+
<!--
24+
OR provide the following.
25+
If possible, whittle down your issue into a [short, self-contained, correct example](http://sscce.org/).
26+
-->
27+
28+
**`@optimizely/optimizely-sdk` version:**
29+
30+
<!-- ...and whichever of the following are applicable: -->
31+
32+
**Browser and version:**
33+
34+
**`node` version:**
35+
36+
**`npm` version:**
37+
38+
Versions of any other relevant tools (like module bundlers, transpilers, etc.):

.github/pull_request_template.md

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
## Summary
2+
- The "what"; a concise description of each logical change
3+
- Another change
4+
5+
The "why", or other context.
6+
7+
## Test plan
8+
9+
## Issues
10+
- "THING-1234" or "Fixes #123"

.github/workflows/integration_test.yml

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Reusable action of running integration of production suite
1+
name: Run Production Suite
22

33
on:
44
workflow_call:
@@ -11,18 +11,18 @@ jobs:
1111
test:
1212
runs-on: ubuntu-latest
1313
steps:
14-
- uses: actions/checkout@v3
14+
- name: Checkout branch
15+
uses: actions/checkout@v3
1516
with:
16-
# You should create a personal access token and store it in your repository
1717
token: ${{ secrets.CI_USER_TOKEN }}
1818
repository: 'optimizely/travisci-tools'
1919
path: 'home/runner/travisci-tools'
2020
ref: 'master'
21-
- name: set SDK Branch if PR
21+
- name: Set SDK branch if PR
2222
if: ${{ github.event_name == 'pull_request' }}
2323
run: |
2424
echo "SDK_BRANCH=${{ github.head_ref }}" >> $GITHUB_ENV
25-
- name: set SDK Branch if not pull request
25+
- name: Set SDK branch if not pull request
2626
if: ${{ github.event_name != 'pull_request' }}
2727
run: |
2828
echo "SDK_BRANCH=${{ github.ref_name }}" >> $GITHUB_ENV

.github/workflows/react.yml

+14-34
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,34 @@
1-
name: react SDK CI
1+
name: React SDK CI
22

33
on:
44
push:
55
branches: [ master ]
6-
tags:
7-
- '[0-9]+.[0-9]+.[0-9]+*'
86
pull_request:
97
branches: [ master ]
108

119
jobs:
12-
unit_tests:
10+
unitTests:
11+
name: Run Unit Tests (Node ${{ matrix.node }})
1312
runs-on: ubuntu-latest
1413
strategy:
1514
matrix:
16-
node: ['14', '16', '18' ]
15+
node: [ '16', '18' ]
1716
steps:
18-
- uses: actions/checkout@v3
17+
- name: Checkout branch
18+
uses: actions/checkout@v3
1919
- name: Set up Node ${{ matrix.node }}
2020
uses: actions/setup-node@v3
2121
with:
2222
node-version: ${{ matrix.node }}
23-
- run: yarn install
24-
- run: yarn test
23+
- name: Install dependencies
24+
run: yarn install
25+
- name: Run tests
26+
run: yarn test
2527

26-
integration_tests:
28+
integration_tests:
29+
name: Run integration tests
30+
needs: [ unitTests ]
2731
uses: optimizely/react-sdk/.github/workflows/integration_test.yml@master
2832
secrets:
2933
CI_USER_TOKEN: ${{ secrets.CI_USER_TOKEN }}
30-
TRAVIS_COM_TOKEN: ${{ secrets.TRAVIS_COM_TOKEN }}
31-
32-
publish:
33-
if: startsWith(github.ref, 'refs/tags/')
34-
runs-on: ubuntu-latest
35-
steps:
36-
- uses: actions/checkout@v3
37-
- name: install
38-
run: |
39-
URL=$(curl https://api.github.com/repos/github/hub/releases/latest 2>/dev/null | jq -r '.assets[] | select(.browser_download_url | contains("linux-amd64")) | .browser_download_url')
40-
curl -fsSL "$URL" | tar xz -C /tmp --strip-components=1 --wildcards '*/bin/hub'
41-
echo "${HOME}/.local/bin" >> $GITHUB_PATH
42-
hub version
43-
- name: Get the version
44-
id: get_version
45-
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
46-
- name: set the env
47-
run: echo "travis_tag=${{ steps.get_version.outputs.VERSION }}" >> $GITHUB_ENV
48-
- name: script
49-
run: |
50-
NEW_VERSION=$(grep -P '^## \[\d+\.\d+\.\d+.*\]' CHANGELOG.md | awk 'NR==1' | sed -e 's/\[/\\\[/' | sed -e 's/\]/\\\]/')
51-
LAST_VERSION=$(grep -P '^## \[\d+\.\d+\.\d+.*\]' CHANGELOG.md | awk 'NR==2' | sed -e 's/\[/\\\[/' | sed -e 's/\]/\\\]/')
52-
DESCRIPTION=$(awk "/^${NEW_VERSION}$/,/^${LAST_VERSION:-nothingmatched}$/" CHANGELOG.md | grep -v "^${LAST_VERSION:-nothingmatched}$")
53-
hub release create -m "Release ${{ env.travis_tag }}" -m "${DESCRIPTION}" "${{ env.travis_tag }}"
54-
34+
TRAVIS_COM_TOKEN: ${{ secrets.TRAVIS_COM_TOKEN }}

.github/workflows/react_release.yml

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Publish React SDK to NPM
2+
3+
on:
4+
release:
5+
types: [ published ]
6+
7+
jobs:
8+
publish:
9+
name: Publish to npm
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout branch
13+
uses: actions/checkout@v3
14+
- name: Set up Node
15+
uses: actions/setup-node@v3
16+
with:
17+
node-version: 18
18+
- name: Install dependencies
19+
run: yarn install
20+
- name: Run npm publish command
21+
env:
22+
NODE_AUTH_TOKEN: ${{ secrets.PUBLISH_REACT_SDK_TO_NPM }}
23+
run: npm publish
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Jira ticket reference check
1+
name: Jira Ticket Reference Check
22

33
on:
44
pull_request:
@@ -7,10 +7,10 @@ on:
77
jobs:
88

99
jira_ticket_reference_check:
10+
name: Check PR description has Jira number
1011
runs-on: ubuntu-latest
11-
1212
steps:
13-
- name: Check for Jira ticket reference
13+
- name: Call ticket reference checker
1414
uses: optimizely/github-action-ticket-reference-checker-public@master
1515
with:
1616
bodyRegex: 'FSSDK-(?<ticketNumber>\d+)'

.nvmrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v10
1+
v18

.vscode/settings.json

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"jest.autoRun": {
3+
"onStartup": [
4+
"all-tests"
5+
]
6+
},
7+
}

0 commit comments

Comments
 (0)