Skip to content

Commit

Permalink
prepare for v1 (#6)
Browse files Browse the repository at this point in the history
* prepare for v1

* add usage docs

* pretty

* current url use channel and test version install

* bunble

* formatting test
  • Loading branch information
markandersontrocme authored Dec 6, 2024
1 parent 2224f52 commit 53fe639
Show file tree
Hide file tree
Showing 19 changed files with 2,940 additions and 4,083 deletions.
42 changes: 28 additions & 14 deletions .github/linters/.eslintrc.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
env:
commonjs: true
node: true
es6: true
jest: true
node: true

globals:
Atomics: readonly
Expand All @@ -15,24 +14,22 @@ ignorePatterns:
- '**/coverage/.*'
- '*.json'

parser: '@babel/eslint-parser'
parser: '@typescript-eslint/parser'

parserOptions:
ecmaVersion: 2023
sourceType: module
requireConfigFile: false
babelOptions:
babelrc: false
configFile: false
presets:
- jest
project:
- './.github/linters/tsconfig.json'
- './tsconfig.json'

plugins:
- jest
- '@typescript-eslint'

extends:
- eslint:recommended
- plugin:github/recommended
- plugin:@typescript-eslint/recommended-type-checked
- plugin:jest/recommended

rules:
Expand All @@ -41,10 +38,27 @@ rules:
'eslint-comments/no-use': 'off',
'eslint-comments/no-unused-disable': 'off',
'i18n-text/no-en': 'off',
'import/no-commonjs': 'off',
'import/no-namespace': 'off',
'no-console': 'off',
'no-unused-vars': 'off',
'prettier/prettier': 'error',
'semi': 'off'
'semi': 'off',
'@typescript-eslint/array-type': 'error',
'@typescript-eslint/consistent-type-assertions': 'error',
'@typescript-eslint/explicit-member-accessibility':
['error', { 'accessibility': 'no-public' }],
'@typescript-eslint/explicit-function-return-type':
['error', { 'allowExpressions': true }],
'@typescript-eslint/no-empty-interface': 'error',
'@typescript-eslint/no-extraneous-class': 'error',
'@typescript-eslint/no-inferrable-types': 'error',
'@typescript-eslint/no-non-null-assertion': 'warn',
'@typescript-eslint/no-unnecessary-qualifier': 'error',
'@typescript-eslint/no-useless-constructor': 'error',
'@typescript-eslint/no-var-requires': 'error',
'@typescript-eslint/prefer-for-of': 'warn',
'@typescript-eslint/prefer-function-type': 'warn',
'@typescript-eslint/prefer-includes': 'error',
'@typescript-eslint/prefer-string-starts-ends-with': 'error',
'@typescript-eslint/promise-function-async': 'error',
'@typescript-eslint/require-array-sort-compare': 'error',
'@typescript-eslint/space-before-function-paren': 'off'
}
9 changes: 9 additions & 0 deletions .github/linters/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{

Check warning on line 1 in .github/linters/tsconfig.json

View workflow job for this annotation

GitHub Actions / Lint Codebase

File ignored by default.

Check warning on line 1 in .github/linters/tsconfig.json

View workflow job for this annotation

GitHub Actions / Lint Codebase

File ignored by default.

Check warning on line 1 in .github/linters/tsconfig.json

View workflow job for this annotation

GitHub Actions / Lint Codebase

File ignored by default.

Check warning on line 1 in .github/linters/tsconfig.json

View workflow job for this annotation

GitHub Actions / Lint Codebase

File ignored by default.

Check warning on line 1 in .github/linters/tsconfig.json

View workflow job for this annotation

GitHub Actions / Lint Codebase

File ignored by default.
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "../../tsconfig.json",
"compilerOptions": {
"noEmit": true
},
"include": ["../../__tests__/**/*", "../../src/**/*"],
"exclude": ["../../dist", "../../node_modules", "../../coverage", "*.json"]
}
51 changes: 48 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,54 @@ jobs:
id: checkout
uses: actions/checkout@v4

- name: Test Local Action
- name: Install up
id: test-action
uses: ./
with:
token: test-token
skip_login: true
api-token: ${{ secrets.UP_API_TOKEN }}
organization: github-actions-test

- name: Verify Installation
run: up version

test-action-skip-login:
name: GitHub Actions Test skip-login
runs-on: ubuntu-latest

steps:
- name: Checkout
id: checkout
uses: actions/checkout@v4

- name: Install up
id: test-action
uses: ./
with:
skip-login: true

- name: Verify Installation
run: up version

test-action-skip-login-custom-version:
name: GitHub Actions Test custom version
runs-on: ubuntu-latest

steps:
- name: Checkout
id: checkout
uses: actions/checkout@v4

- name: Install up
id: test-action
uses: ./
with:
version: v0.32.0
skip-login: true

- name: Verify Installation
run: |
INSTALLED_VERSION=$(up version --client | yq .Client.Version)
if [[ "$INSTALLED_VERSION" != "v0.32.0" ]]; then
echo "Error: Expected version v0.32.0 but got $INSTALLED_VERSION"
exit 1
fi
3 changes: 2 additions & 1 deletion .github/workflows/linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ jobs:
DEFAULT_BRANCH: main
FILTER_REGEX_EXCLUDE: dist/**/*
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VALIDATE_JAVASCRIPT_STANDARD: false
VALIDATE_ALL_CODEBASE: true
VALIDATE_JAVASCRIPT_STANDARD: false
VALIDATE_JSCPD: false
VALIDATE_TYPESCRIPT_STANDARD: false
25 changes: 24 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,30 @@ This action enabbles you to interact with Upbound by installing the up CLI.

## Usage

TODO
To install the latest version of `up` and use it in GitHub Actions workflows,
[create an Upbound API token](https://docs.upbound.io/all-spaces/spaces/console/#create-a-personal-access-token),
[add it as a secret to your repository](https://docs.github.com/en/actions/security-for-github-actions/security-guides/using-secrets-in-github-actions#creating-encrypted-secrets-for-a-repository),
and add the following step to your workflow:

```yaml
- name: Install and login with up
uses: upbound/action-up@v0.1.0
with:
token: ${{ secrets.UP_API_TOKEN }}
```
`up` will now be available in the environement and can be used in follow steps.
As an example, you can set your Upbound context:

```yaml
- name: Install and login with up
uses: upbound/action-up@v0.1.0
with:
token: ${{ secrets.UP_API_TOKEN }}
- name: Set Upbound context
run: up ctx my-org/upbound-gcp-us-west-1/default/my-ctp
```

## Contributing

Expand Down
18 changes: 0 additions & 18 deletions __tests__/index.test.js

This file was deleted.

17 changes: 17 additions & 0 deletions __tests__/index.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* Unit tests for the action's entrypoint, src/index.js
*/

import * as main from '../src/main'

// Mock the action's entrypoint
const runMock = jest.spyOn(main, 'run').mockImplementation()

describe('index', () => {
it('calls run when imported', () => {
// eslint-disable-next-line @typescript-eslint/no-require-imports
require('../src/index')

expect(runMock).toHaveBeenCalled()
})
})
123 changes: 0 additions & 123 deletions __tests__/main.test.js

This file was deleted.

Loading

0 comments on commit 53fe639

Please sign in to comment.