Skip to content

Commit

Permalink
add
Browse files Browse the repository at this point in the history
add

add

add

Update main.ts

Update main.ts

add

add

add

add

add

add

Update main.ts

add

add

add

add

refine

add

add

fix

fromjson

add

add

add

add

add

add

add

add

add

add

add

add

add

add

add

add

add

add

add

add

add action

add

add

add

add

rm tests

add

add files

add

add

add

add

add

add

add

add

add

add

add

add

add

add

add

add

add

add

add

add

add

add

add

add

fix

add
  • Loading branch information
jackalcooper committed Jul 2, 2024
1 parent 806f096 commit d6bedad
Show file tree
Hide file tree
Showing 16 changed files with 87,000 additions and 20,813 deletions.
6 changes: 4 additions & 2 deletions .github/linters/.eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ rules:
'eslint-comments/no-unused-disable': 'off',
'i18n-text/no-en': 'off',
'import/no-namespace': 'off',
'import/no-commonjs': 'off',
'import/first': 'off',
'no-console': 'off',
'no-unused-vars': 'off',
'prettier/prettier': 'error',
Expand All @@ -63,12 +65,12 @@ rules:
'@typescript-eslint/no-misused-new': 'error',
'@typescript-eslint/no-namespace': 'error',
'@typescript-eslint/no-non-null-assertion': 'warn',
'@typescript-eslint/no-require-imports': 'error',
'@typescript-eslint/no-require-imports': 'off',
'@typescript-eslint/no-unnecessary-qualifier': 'error',
'@typescript-eslint/no-unnecessary-type-assertion': 'error',
'@typescript-eslint/no-unused-vars': 'error',
'@typescript-eslint/no-useless-constructor': 'error',
'@typescript-eslint/no-var-requires': 'error',
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/prefer-for-of': 'warn',
'@typescript-eslint/prefer-function-type': 'warn',
'@typescript-eslint/prefer-includes': 'error',
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/check-dist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ on:
branches:
- main

concurrency:
group: hf-oss-dist-${{ github.ref }}
cancel-in-progress: true

permissions:
contents: read

Expand Down
42 changes: 37 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ on:

permissions:
contents: read
env:
OSS_ACCESS_KEY_ID: ${{ secrets.OSS_ACCESS_KEY_ID }}
OSS_ACCESS_KEY_SECRET: ${{ secrets.OSS_ACCESS_KEY_SECRET }}

concurrency:
group: hf-oss-ci-${{ github.ref }}
cancel-in-progress: true

jobs:
test-typescript:
Expand Down Expand Up @@ -44,21 +51,46 @@ jobs:
id: npm-ci-test
run: npm run ci-test

test-action:
list:
name: GitHub Actions Test
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.list-action.outputs.matrix }}

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

- run: git clone https://huggingface.co/J5Tsai/debug-static-files
env:
GIT_LFS_SKIP_SMUDGE: 1

- name: Test Local Action
id: test-action
uses: ./
id: list-action
uses: ./actions/list
with:
milliseconds: 2000
repo-dir: debug-static-files

- name: Print Output
id: output
run: echo "${{ steps.test-action.outputs.time }}"
run: echo "${{ steps.list-action.outputs.matrix }}"

sync-oss:
name: 'Sync to OSS'
runs-on: ubuntu-latest
needs: list
strategy:
fail-fast: false
max-parallel: 12
matrix: ${{ fromJson(needs.list.outputs.matrix) }}
steps:
- name: Checkout
id: checkout
uses: actions/checkout@v4

- name: Test Local Action
id: list-action
uses: ./actions/sync
with:
urls: ${{ matrix.task.urls }}
4 changes: 4 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ on:
schedule:
- cron: '31 7 * * 3'

concurrency:
group: hf-code-ci-${{ github.ref }}
cancel-in-progress: true

permissions:
actions: read
checks: write
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ permissions:
packages: read
statuses: write

concurrency:
group: hf-oss-linter-${{ github.ref }}
cancel-in-progress: true

jobs:
lint:
name: Lint Codebase
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# Development

```bash
GIT_LFS_SKIP_SMUDGE=1 git clone https://huggingface.co/J5Tsai/debug-static-file
```

# Create a GitHub Action Using TypeScript

[![GitHub Super-Linter](https://github.com/actions/typescript-action/actions/workflows/linter.yml/badge.svg)](https://github.com/super-linter/super-linter)
Expand Down
65 changes: 19 additions & 46 deletions __tests__/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,78 +12,51 @@ import * as main from '../src/main'
// Mock the action's main function
const runMock = jest.spyOn(main, 'run')

// Other utilities
const timeRegex = /^\d{2}:\d{2}:\d{2}/

// Mock the GitHub Actions core library
let debugMock: jest.SpiedFunction<typeof core.debug>
let errorMock: jest.SpiedFunction<typeof core.error>
let getInputMock: jest.SpiedFunction<typeof core.getInput>
let setFailedMock: jest.SpiedFunction<typeof core.setFailed>
let setOutputMock: jest.SpiedFunction<typeof core.setOutput>

describe('action', () => {
beforeEach(() => {
jest.clearAllMocks()

debugMock = jest.spyOn(core, 'debug').mockImplementation()
errorMock = jest.spyOn(core, 'error').mockImplementation()
getInputMock = jest.spyOn(core, 'getInput').mockImplementation()
setFailedMock = jest.spyOn(core, 'setFailed').mockImplementation()
setOutputMock = jest.spyOn(core, 'setOutput').mockImplementation()
})

it('sets the time output', async () => {
it('sets the file output', async () => {
// Set the action's inputs as return values from core.getInput()
getInputMock.mockImplementation(name => {
switch (name) {
case 'milliseconds':
return '500'
case 'repo-dir':
return getRepoDir()
case 'repo-ref':
return 'main'
case 'action':
return 'list'
default:
return ''
}
})

await main.run()
expect(runMock).toHaveReturned()

// Verify that all of the core library functions were called correctly
expect(debugMock).toHaveBeenNthCalledWith(1, 'Waiting 500 milliseconds ...')
expect(debugMock).toHaveBeenNthCalledWith(
2,
expect.stringMatching(timeRegex)
)
expect(debugMock).toHaveBeenNthCalledWith(
3,
expect.stringMatching(timeRegex)
)
expect(setOutputMock).toHaveBeenNthCalledWith(1, 'file', '.gitattributes')
expect(setOutputMock).toHaveBeenNthCalledWith(3, 'lfs', 'sd3demo.jpg')
expect(setOutputMock).toHaveBeenNthCalledWith(
1,
'time',
expect.stringMatching(timeRegex)
)
expect(errorMock).not.toHaveBeenCalled()
})

it('sets a failed status', async () => {
// Set the action's inputs as return values from core.getInput()
getInputMock.mockImplementation(name => {
switch (name) {
case 'milliseconds':
return 'this is not a number'
default:
return ''
}
})

await main.run()
expect(runMock).toHaveReturned()

// Verify that all of the core library functions were called correctly
expect(setFailedMock).toHaveBeenNthCalledWith(
1,
'milliseconds not a number'
4,
'lfs_url',
expect.stringMatching(
/https:\/\/huggingface.co\/J5Tsai\/debug-static-files\/resolve\/.+\/sd3demo.jpg/
)
)
expect(errorMock).not.toHaveBeenCalled()
})
})
function getRepoDir(): string {
const fromEnv = process.env.HF_TO_OSS_DEBUG_REPO_DIR
if (fromEnv) return fromEnv
throw new Error('Function not implemented.')
}
25 changes: 0 additions & 25 deletions __tests__/wait.test.ts

This file was deleted.

32 changes: 32 additions & 0 deletions actions/list/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: 'list git large files'
description: 'Provide a description here'
author: 'Your name or organization here'

# Add your action's branding here. This will appear on the GitHub Marketplace.
branding:
icon: 'heart'
color: 'red'

# Define your inputs here.
inputs:
action:
description: ''
required: false
default: 'list'
repo-dir:
description: 'Your input description here'
required: true
default: '1000'
repo-ref:
description: 'Your input description here'
required: false
default: 'HEAD'

# Define your outputs here.
outputs:
matrix:
description: ''

runs:
using: node20
main: ../../dist/index.js
22 changes: 22 additions & 0 deletions actions/sync/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: 'sync git large files'
description: 'Provide a description here'
author: 'Your name or organization here'

# Add your action's branding here. This will appear on the GitHub Marketplace.
branding:
icon: 'heart'
color: 'red'

# Define your inputs here.
inputs:
action:
description: ''
required: false
default: 'sync'
urls:
description: 'Your input description here'
required: true

runs:
using: node20
main: ../../dist/index.js
2 changes: 1 addition & 1 deletion badges/coverage.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit d6bedad

Please sign in to comment.