Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #470 from akv-platform/apply-reusable-workflows
Update action to use reusable workflows
  • Loading branch information
Ivan authored and GitHub committed Dec 22, 2022
2 parents f7b1827 + 55e1958 commit 91690a7
Show file tree
Hide file tree
Showing 17 changed files with 278 additions and 307 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/basic-validation.yml
@@ -0,0 +1,17 @@
name: Basic validation

on:
pull_request:
paths-ignore:
- '**.md'
push:
branches:
- main
- releases/*
paths-ignore:
- '**.md'

jobs:
call-basic-validation:
name: Basic validation
uses: actions/reusable-workflows/.github/workflows/basic-validation.yml@main
28 changes: 0 additions & 28 deletions .github/workflows/build_test.yml

This file was deleted.

41 changes: 3 additions & 38 deletions .github/workflows/check-dist.yml
@@ -1,8 +1,3 @@
# `dist/index.js` is a special file in Actions.
# When you reference an action with `uses:` in a workflow,
# `index.js` is the code that will run.
# For our project, we generate this file through a build process from other source files.
# We need to make sure the checked-in `index.js` actually matches what we expect it to be.
name: Check dist/

on:
Expand All @@ -17,36 +12,6 @@ on:
workflow_dispatch:

jobs:
check-dist:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Set Node.js 16.x
uses: actions/setup-node@v3
with:
node-version: 16.x
cache: npm

- name: Install dependencies
run: npm ci

- name: Rebuild the dist/ directory
run: npm run build

- name: Compare the expected and actual dist/ directories
run: |
if [ "$(git diff --ignore-space-at-eol dist/ | wc -l)" -gt "0" ]; then
echo "Detected uncommitted changes after build. See status below:"
git diff
exit 1
fi
id: diff

# If index.js was different than expected, upload the expected version as an artifact
- uses: actions/upload-artifact@v3
if: ${{ failure() && steps.diff.conclusion == 'failure' }}
with:
name: dist
path: dist/
call-check-dist:
name: Check dist/
uses: actions/reusable-workflows/.github/workflows/check-dist.yml@main
14 changes: 14 additions & 0 deletions .github/workflows/codeql-analysis.yml
@@ -0,0 +1,14 @@
name: CodeQL analysis

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
schedule:
- cron: '0 3 * * 0'

jobs:
call-codeQL-analysis:
name: CodeQL analysis
uses: actions/reusable-workflows/.github/workflows/codeql-analysis.yml@main
15 changes: 15 additions & 0 deletions .github/workflows/licensed.yml
@@ -0,0 +1,15 @@
name: Licensed

on:
push:
branches:
- main
pull_request:
branches:
- main
workflow_dispatch:

jobs:
call-licensed:
name: Licensed
uses: actions/reusable-workflows/.github/workflows/licensed.yml@main
1 change: 1 addition & 0 deletions .github/workflows/release-new-action-version.yml
@@ -1,4 +1,5 @@
name: Release new action version

on:
release:
types: [released]
Expand Down
50 changes: 0 additions & 50 deletions .github/workflows/update_and_check_licenses.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .licenses/npm/minimatch.dep.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions .prettierrc.json
@@ -0,0 +1,12 @@
{
"printWidth": 80,
"tabWidth": 2,
"useTabs": false,
"semi": true,
"singleQuote": true,
"trailingComma": "none",
"bracketSpacing": false,
"arrowParens": "avoid",
"parser": "typescript",
"endOfLine": "auto"
}
24 changes: 12 additions & 12 deletions __mocks__/@actions/github.ts
@@ -1,34 +1,34 @@
export const context = {
payload: {
pull_request: {
number: 123,
},
number: 123
}
},
repo: {
owner: "monalisa",
repo: "helloworld",
},
owner: 'monalisa',
repo: 'helloworld'
}
};

const mockApi = {
rest: {
issues: {
addLabels: jest.fn(),
removeLabel: jest.fn(),
removeLabel: jest.fn()
},
pulls: {
get: jest.fn().mockResolvedValue({}),
listFiles: {
endpoint: {
merge: jest.fn().mockReturnValue({}),
},
},
merge: jest.fn().mockReturnValue({})
}
}
},
repos: {
getContent: jest.fn(),
},
getContent: jest.fn()
}
},
paginate: jest.fn(),
paginate: jest.fn()
};

export const getOctokit = jest.fn().mockImplementation(() => mockApi);
22 changes: 11 additions & 11 deletions __tests__/labeler.test.ts
@@ -1,27 +1,27 @@
import { checkGlobs } from "../src/labeler";
import {checkGlobs} from '../src/labeler';

import * as core from "@actions/core";
import * as core from '@actions/core';

jest.mock("@actions/core");
jest.mock('@actions/core');

beforeAll(() => {
jest.spyOn(core, "getInput").mockImplementation((name, options) => {
return jest.requireActual("@actions/core").getInput(name, options);
jest.spyOn(core, 'getInput').mockImplementation((name, options) => {
return jest.requireActual('@actions/core').getInput(name, options);
});
});

const matchConfig = [{ any: ["*.txt"] }];
const matchConfig = [{any: ['*.txt']}];

describe("checkGlobs", () => {
it("returns true when our pattern does match changed files", () => {
const changedFiles = ["foo.txt", "bar.txt"];
describe('checkGlobs', () => {
it('returns true when our pattern does match changed files', () => {
const changedFiles = ['foo.txt', 'bar.txt'];
const result = checkGlobs(changedFiles, matchConfig);

expect(result).toBeTruthy();
});

it("returns false when our pattern does not match changed files", () => {
const changedFiles = ["foo.docx"];
it('returns false when our pattern does not match changed files', () => {
const changedFiles = ['foo.docx'];
const result = checkGlobs(changedFiles, matchConfig);

expect(result).toBeFalsy();
Expand Down

0 comments on commit 91690a7

Please sign in to comment.