Skip to content

Commit 078ee7a

Browse files
Github action for feature flags to Azure App Configuration
1 parent 3d51ec1 commit 078ee7a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+89831
-430
lines changed

.devcontainer/devcontainer.json

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"name": "GitHub Actions (TypeScript)",
3+
"image": "mcr.microsoft.com/devcontainers/typescript-node:20",
4+
"postCreateCommand": "npm install",
5+
"customizations": {
6+
"codespaces": {
7+
"openFiles": ["README.md"]
8+
},
9+
"vscode": {
10+
"extensions": [
11+
"bierner.markdown-preview-github-styles",
12+
"davidanson.vscode-markdownlint",
13+
"dbaeumer.vscode-eslint",
14+
"esbenp.prettier-vscode",
15+
"github.copilot",
16+
"github.copilot-chat",
17+
"github.vscode-github-actions",
18+
"github.vscode-pull-request-github",
19+
"me-dutour-mathieu.vscode-github-actions",
20+
"redhat.vscode-yaml",
21+
"rvest.vs-code-prettier-eslint",
22+
"yzhang.markdown-all-in-one"
23+
],
24+
"settings": {
25+
"editor.defaultFormatter": "esbenp.prettier-vscode",
26+
"editor.tabSize": 2,
27+
"editor.formatOnSave": true,
28+
"markdown.extension.list.indentationSize": "adaptive",
29+
"markdown.extension.italic.indicator": "_",
30+
"markdown.extension.orderedList.marker": "one"
31+
}
32+
}
33+
},
34+
"remoteEnv": {
35+
"GITHUB_TOKEN": "${localEnv:GITHUB_TOKEN}"
36+
},
37+
"features": {
38+
"ghcr.io/devcontainers/features/github-cli:1": {},
39+
"ghcr.io/devcontainers-contrib/features/prettier:1": {}
40+
}
41+
}

.gitattributes

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
* text=auto eol=lf
2+
3+
dist/** -diff linguist-generated=true

.github/dependabot.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: github-actions
4+
directory: /
5+
schedule:
6+
interval: weekly
7+
groups:
8+
actions-minor:
9+
update-types:
10+
- minor
11+
- patch
12+
13+
- package-ecosystem: npm
14+
directory: /
15+
schedule:
16+
interval: weekly
17+
groups:
18+
npm-development:
19+
dependency-type: development
20+
update-types:
21+
- minor
22+
- patch
23+
npm-production:
24+
dependency-type: production
25+
update-types:
26+
- patch

.github/linters/.eslintrc.yaml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
env:
2+
node: true
3+
es6: true
4+
jest: true
5+
6+
globals:
7+
Atomics: readonly
8+
SharedArrayBuffer: readonly
9+
10+
ignorePatterns:
11+
- '!.*'
12+
- '**/node_modules/.*'
13+
- '**/dist/.*'
14+
- '**/coverage/.*'
15+
- '*.json'
16+
17+
parser: '@typescript-eslint/parser'
18+
19+
parserOptions:
20+
ecmaVersion: 2023
21+
sourceType: module
22+
project:
23+
- './.github/linters/tsconfig.json'
24+
- './tsconfig.json'
25+
26+
plugins:
27+
- jest
28+
- '@typescript-eslint'
29+
30+
extends:
31+
- eslint:recommended
32+
- plugin:@typescript-eslint/eslint-recommended
33+
- plugin:@typescript-eslint/recommended
34+
- plugin:jest/recommended
35+
36+
rules:
37+
{
38+
'camelcase': 'off',
39+
'eslint-comments/no-use': 'off',
40+
'eslint-comments/no-unused-disable': 'off',
41+
'i18n-text/no-en': 'off',
42+
'import/no-namespace': 'off',
43+
'no-console': 'off',
44+
'no-unused-vars': 'off',
45+
'semi': 'off',
46+
'@typescript-eslint/array-type': 'error',
47+
'@typescript-eslint/await-thenable': 'error',
48+
'@typescript-eslint/ban-ts-comment': 'error',
49+
'@typescript-eslint/consistent-type-assertions': 'error',
50+
'@typescript-eslint/explicit-member-accessibility':
51+
['error', { 'accessibility': 'no-public' }],
52+
'@typescript-eslint/explicit-function-return-type':
53+
['error', { 'allowExpressions': true }],
54+
'@typescript-eslint/no-array-constructor': 'error',
55+
'@typescript-eslint/no-empty-interface': 'error',
56+
'@typescript-eslint/no-explicit-any': 'error',
57+
'@typescript-eslint/no-extraneous-class': 'error',
58+
'@typescript-eslint/no-for-in-array': 'error',
59+
'@typescript-eslint/no-inferrable-types': 'error',
60+
'@typescript-eslint/no-misused-new': 'error',
61+
'@typescript-eslint/no-namespace': 'error',
62+
'@typescript-eslint/no-non-null-assertion': 'warn',
63+
'@typescript-eslint/no-require-imports': 'error',
64+
'@typescript-eslint/no-unnecessary-qualifier': 'error',
65+
'@typescript-eslint/no-unnecessary-type-assertion': 'error',
66+
'@typescript-eslint/no-unused-vars': 'error',
67+
'@typescript-eslint/no-useless-constructor': 'error',
68+
'@typescript-eslint/no-var-requires': 'error',
69+
'@typescript-eslint/prefer-for-of': 'warn',
70+
'@typescript-eslint/prefer-function-type': 'warn',
71+
'@typescript-eslint/prefer-includes': 'error',
72+
'@typescript-eslint/prefer-string-starts-ends-with': 'error',
73+
'@typescript-eslint/promise-function-async': 'error',
74+
'@typescript-eslint/require-array-sort-compare': 'error',
75+
'@typescript-eslint/restrict-plus-operands': 'error',
76+
'@typescript-eslint/space-before-function-paren': 'off',
77+
'@typescript-eslint/unbound-method': 'error'
78+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Unordered list style
2+
MD004:
3+
style: dash
4+
5+
# Ordered list item prefix
6+
MD029:
7+
style: one
8+
9+
# Spaces after list markers
10+
MD030:
11+
ul_single: 1
12+
ol_single: 1
13+
ul_multi: 1
14+
ol_multi: 1
15+
16+
# Code block style
17+
MD046:
18+
style: fenced

.github/linters/.yaml-lint.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
rules:
2+
document-end: disable
3+
document-start:
4+
level: warning
5+
present: false
6+
line-length:
7+
level: warning
8+
max: 80
9+
allow-non-breakable-words: true
10+
allow-non-breakable-inline-mappings: true

.github/linters/tsconfig.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"$schema": "https://json.schemastore.org/tsconfig",
3+
"extends": "../../tsconfig.json",
4+
"compilerOptions": {
5+
"noEmit": true
6+
},
7+
"include": ["../../__tests__/**/*", "../../src/**/*"],
8+
"exclude": ["../../dist", "../../node_modules", "../../coverage", "*.json"]
9+
}

.github/workflows/check-dist.yml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# In TypeScript actions, `dist/` is a special directory. When you reference
2+
# an action with the `uses:` property, `dist/index.js` is the code that will be
3+
# run. For this project, the `dist/index.js` file is transpiled from other
4+
# source files. This workflow ensures the `dist/` directory contains the
5+
# expected transpiled code.
6+
#
7+
# If this workflow is run from a feature branch, it will act as an additional CI
8+
# check and fail if the checked-in `dist/` directory does not match what is
9+
# expected from the build.
10+
name: Check Transpiled JavaScript
11+
12+
on:
13+
pull_request:
14+
branches:
15+
- main
16+
push:
17+
branches:
18+
- main
19+
20+
permissions:
21+
contents: read
22+
23+
jobs:
24+
check-dist:
25+
name: Check dist/
26+
runs-on: ubuntu-latest
27+
28+
steps:
29+
- name: Checkout
30+
id: checkout
31+
uses: actions/checkout@v4
32+
33+
- name: Setup Node.js
34+
id: setup-node
35+
uses: actions/setup-node@v4
36+
with:
37+
node-version-file: .node-version
38+
cache: npm
39+
40+
- name: Install Dependencies
41+
id: install
42+
run: npm ci
43+
44+
- name: Build dist/ Directory
45+
id: build
46+
run: npm run bundle
47+
48+
# This will fail the workflow if the `dist/` directory is different than
49+
# expected.
50+
- name: Compare Directories
51+
id: diff
52+
run: |
53+
if [ ! -d dist/ ]; then
54+
echo "Expected dist/ directory does not exist. See status below:"
55+
ls -la ./
56+
exit 1
57+
fi
58+
if [ "$(git diff --ignore-space-at-eol --text dist/ | wc -l)" -gt "0" ]; then
59+
echo "Detected uncommitted changes after build. See status below:"
60+
git diff --ignore-space-at-eol --text dist/
61+
exit 1
62+
fi
63+
64+
# If `dist/` was different than expected, upload the expected version as a
65+
# workflow artifact.
66+
- if: ${{ failure() && steps.diff.outcome == 'failure' }}
67+
name: Upload Artifact
68+
id: upload
69+
uses: actions/upload-artifact@v4
70+
with:
71+
name: dist
72+
path: dist/

.github/workflows/ci.yml

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
name: Continuous Integration
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
branches:
7+
- main
8+
push:
9+
branches:
10+
- main
11+
12+
permissions:
13+
id-token: write
14+
contents: read
15+
16+
jobs:
17+
test-typescript:
18+
name: TypeScript Tests
19+
runs-on: ubuntu-latest
20+
21+
steps:
22+
- name: Checkout
23+
id: checkout
24+
uses: actions/checkout@v4
25+
26+
- name: Setup Node.js
27+
id: setup-node
28+
uses: actions/setup-node@v4
29+
with:
30+
node-version-file: .node-version
31+
cache: npm
32+
33+
- name: Install Dependencies
34+
id: npm-ci
35+
run: npm ci
36+
37+
- name: Check Format
38+
id: npm-format-check
39+
run: npm run format:check
40+
41+
- name: Test
42+
id: npm-ci-test
43+
run: npm run ci-test
44+
45+
test-action:
46+
name: GitHub Actions Test
47+
runs-on: ubuntu-latest
48+
49+
steps:
50+
- name: Checkout
51+
id: checkout
52+
uses: actions/checkout@v4
53+
54+
- name: Azure login using Federated Credentials
55+
uses: azure/login@v2
56+
with:
57+
client-id: ${{ vars.AZURE_CLIENT_ID }}
58+
tenant-id: ${{ vars.AZURE_TENANT_ID }}
59+
subscription-id: ${{ vars.AZURE_SUBSCRIPTION_ID }}
60+
enable-AzPSSession: true
61+
62+
- name: Test Local Action
63+
id: test-action
64+
uses: ./
65+
with:
66+
path: TestData/*.json
67+
app-configuration-endpoint: ${{ vars.APP_CONFIGURATION_ENDPOINT }}
68+
strict: true
69+
70+
- name: Test Local Action file path
71+
id: test-action-2
72+
uses: ./
73+
with:
74+
path: |
75+
TestData/feature-flags.json
76+
TestData/feature-flags2.json
77+
app-configuration-endpoint: ${{ vars.APP_CONFIGURATION_ENDPOINT }}
78+
strict: true
79+
80+
- name: Test Local Action file path 3
81+
id: test-action-3
82+
uses: ./
83+
with:
84+
path: |
85+
TestData/*.json
86+
!TestData/feature-flags3.json
87+
app-configuration-endpoint: ${{ vars.APP_CONFIGURATION_ENDPOINT }}
88+
strict: true

0 commit comments

Comments
 (0)