Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/npm_and_yarn/actions/core-1.10.1
Browse files Browse the repository at this point in the history
  • Loading branch information
markphelps authored Dec 11, 2023
2 parents b27608e + a03b36a commit d1fbc78
Show file tree
Hide file tree
Showing 8 changed files with 750 additions and 3,103 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ jobs:
steps:
- name: Generate token
id: generate_token
uses: tibdex/github-app-token@v1
uses: tibdex/github-app-token@v2
with:
app_id: ${{ secrets.FLIPT_RELEASE_BOT_APP_ID }}
private_key: ${{ secrets.FLIPT_RELEASE_BOT_APP_PEM }}
installation_id: ${{ secrets.FLIPT_RELEASE_BOT_INSTALLATION_ID }}

- uses: google-github-actions/release-please-action@v3
- uses: google-github-actions/release-please-action@v4
with:
token: ${{ steps.generate_token.outputs.token }}
command: manifest
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: 'build-test'
on:
workflow_dispatch:
pull_request:
push:
branches:
Expand Down
2,626 changes: 97 additions & 2,529 deletions dist/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

1,172 changes: 619 additions & 553 deletions package-lock.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@
"node-fetch": "^3.3.2"
},
"devDependencies": {
"@types/node": "^20.5.9",
"@types/node": "^20.10.4",
"@typescript-eslint/parser": "^5.62.0",
"@vercel/ncc": "^0.38.0",
"eslint": "^8.48.0",
"eslint": "^8.55.0",
"eslint-plugin-github": "^4.10.0",
"eslint-plugin-jest": "^27.2.3",
"jest": "^29.6.4",
"jest": "^29.7.0",
"js-yaml": "^4.1.0",
"prettier": "^3.0.3",
"ts-jest": "^29.1.1",
Expand Down
7 changes: 5 additions & 2 deletions src/lib/exec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as aexec from '@actions/exec';
import * as core from '@actions/core';

export interface ExecResult {
success: boolean;
Expand All @@ -9,14 +10,16 @@ export interface ExecResult {
export const exec = async (
command: string,
args: string[] = [],
silent?: boolean,
opts = {},
): Promise<ExecResult> => {
const eopts: aexec.ExecOptions = {
silent: silent,
silent: false,
ignoreReturnCode: true,
...opts,
};

core.debug(`running ${command} ${args.join(' ')}, opts: ${JSON.stringify(eopts)}`);

const { exitCode, stdout, stderr } = await aexec.getExecOutput(
command,
args,
Expand Down
35 changes: 22 additions & 13 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as core from '@actions/core'
import * as glob from '@actions/glob'
import {downloadFlipt} from './lib/cli'
import {environmentVariables} from './lib/environment'
import {exec} from './lib/exec'
Expand Down Expand Up @@ -38,13 +37,14 @@ async function validate(args: string[] = []): Promise<void> {

core.startGroup('Running flipt validate')

const globber = await glob.create(`${workspace}/**/*/features.yaml`)
const files = await globber.glob()

const result = await exec(
'flipt',
['validate', files.join(' '), '--issue-exit-code=0', '--format=json'],
false
['validate', '--issue-exit-code=0', '--format=json'],
{
env: {
FLIPT_LOG_LEVEL: 'fatal'
}
}
)

core.endGroup()
Expand All @@ -54,7 +54,18 @@ async function validate(args: string[] = []): Promise<void> {
return
}

const response = result.stdout
// TODO: hack to get second line of output until env vars can override default config
const lines = result.stdout.toString().split('\n')
if (lines.length < 2) {
core.setFailed('flipt validate returned invalid output')
return
}

// get second line of output
const line = lines[1]

const response = line.trim()

core.debug(`flipt response: ${response}`)

if (response.length === 0) {
Expand All @@ -66,13 +77,11 @@ async function validate(args: string[] = []): Promise<void> {
let errors = 0
const json = JSON.parse(response)

if (!json.errors || json.errors.length === 0) {
core.debug('flipt returned no errors')
core.info('✅ No invalid files found')
return
}
// reponse looks like :
// [{"message":"flags.0.rules.0.distributions.0.rollout: invalid value 110 (out of bound \\u003c=100)","location":{"file":"features.yaml","line":17}}]
// loop through objects in response

for (const error of json.errors) {
for (const error of json) {
errors += 1
const {message, location} = error

Expand Down

0 comments on commit d1fbc78

Please sign in to comment.