Skip to content

Commit

Permalink
refactor: update devcontainer (#129)
Browse files Browse the repository at this point in the history
* refactor: update devcontainer

* fix: shellcheck error

* ci: add timeout
  • Loading branch information
okhiroyuki authored Aug 18, 2024
1 parent a5afa61 commit ff17e52
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 54 deletions.
7 changes: 3 additions & 4 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ FROM koalaman/shellcheck:v0.10.0 AS shellcheck

FROM mcr.microsoft.com/devcontainers/typescript-node:1-18

COPY --from=dockerfile-lint /bin/hadolint /usr/bin/hadolint
COPY --from=shellcheck /bin/shellcheck /usr/bin/

# hadolint ignore=DL3008
RUN apt-get update && apt-get install -y --no-install-recommends \
pre-commit \
&& apt-get clean && rm -rf /var/lib/apt/lists/*

COPY --from=dockerfile-lint /bin/hadolint /usr/bin/hadolint

COPY --from=shellcheck /bin/shellcheck /usr/bin/
8 changes: 4 additions & 4 deletions .devcontainer/commands/post-attach.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#!/bin/bash

if [ ! \( -f .git/hooks/pre-commit \) ]; then
pre-commit install
fi

sudo chown "$USER" .pre-commit-cache
sudo chown "$USER" .npm
sudo chown "$USER" node_modules

if [ ! \( -f .git/hooks/pre-commit \) ]; then
pre-commit install
fi

npm ci
6 changes: 3 additions & 3 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
"ghcr.io/devcontainers/features/java:1": {
"version": "17",
"installGradle": true
},
"ghcr.io/akhildevelops/devcontainer-features/android-cli:0.0.2": {
"PACKAGES": "platform-tools,platforms;android-34,build-tools;34.0.0,ndk-bundle,ndk;24.0.8215888,cmake;3.22.1"
}
// "ghcr.io/akhildevelops/devcontainer-features/android-cli:0": {
// "PACKAGES": "platform-tools,platforms;android-33,build-tools;33.0.2,ndk-bundle,ndk;24.0.8215888,cmake;3.22.1"
// }
},
"mounts": [
"source=node_modules_${devcontainerId},target=${containerWorkspaceFolder}/node_modules,type=volume",
Expand Down
31 changes: 17 additions & 14 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,37 +12,40 @@ env:
jobs:
test:
runs-on: ubuntu-latest
timeout-minutes: 1
steps:
- name: Clone repo
uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v4
- uses: actions/checkout@v4
with:
node-version: "18"
fetch-depth: 0
- uses: actions/checkout@v4
with:
repository: okhiroyuki/composite-actions
path: ./.github/actions/composite-actions
- uses: ./.github/actions/composite-actions/setup-node
- name: npm test
run: |
npm ci
npm test --if-present
run: npm test --if-present
env:
CI: true
build:
runs-on: ubuntu-latest
timeout-minutes: 5
needs: test
steps:
- name: Clone repo
uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v4
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/checkout@v4
with:
node-version: "18"
repository: okhiroyuki/composite-actions
path: ./.github/actions/composite-actions
- uses: ./.github/actions/composite-actions/setup-node
- name: set up JDK
uses: actions/setup-java@v4
with:
distribution: ${{env.JAVA_DISTRIBUTION}}
java-version: ${{env.JAVA_VERSION}}
- name: npm run build
run: |
npm ci
npm run build --if-present
env:
CI: true
42 changes: 20 additions & 22 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
@@ -1,34 +1,32 @@
---
name: npm publish

"on":
# yamllint disable-line rule:truthy
on:
workflow_run:
workflows: [Node.js]
branches: [main]
types: [completed]
workflows:
- Node.js
branches:
- main
types:
- completed

jobs:
publish:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-latest
timeout-minutes: 5
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "20"
- uses: JS-DevTools/npm-publish@v3
id: publish
- uses: actions/checkout@v4
with:
token: ${{ secrets.NPM_TOKEN }}
- name: Create Release
if: ${{ steps.publish.outputs.type }}
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
repository: okhiroyuki/composite-actions
path: ./.github/actions/composite-actions
- uses: ./.github/actions/composite-actions/setup-node
- name: build
run: npm run build
- uses: ./.github/actions/composite-actions/npm-publish
with:
tag_name: ${{ steps.publish.outputs.version }}
release_name: Release ${{ steps.publish.outputs.version }}
body: ${{ steps.publish.outputs.version }}
draft: false
prerelease: false
npm-token: ${{ secrets.NPM_TOKEN }}
15 changes: 10 additions & 5 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
---
name: pre-commit

"on":
# yamllint disable-line rule:truthy
on:
pull_request:
push:
branches: [main]
branches:
- main

jobs:
pre-commit:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
- uses: actions/checkout@v4
with:
python-version: "3.12"
- uses: pre-commit/[email protected]
repository: okhiroyuki/composite-actions
path: ./.github/actions/composite-actions
- uses: ./.github/actions/composite-actions/setup-node
- uses: ./.github/actions/composite-actions/pre-commit
2 changes: 1 addition & 1 deletion dprint.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"lineEnding": "lf"
},
"yaml": {},
"excludes": ["**/*-lock.json", "**/node_modules"],
"excludes": ["**/*-lock.json"],
"plugins": [
"https://plugins.dprint.dev/markdown-0.17.4.wasm",
"https://plugins.dprint.dev/toml-0.6.2.wasm",
Expand Down
2 changes: 1 addition & 1 deletion install/sample-project/copy-sample-project.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
SRC_PATH="plugins/@red-mobile/nodejs-mobile-cordova/install/sample-project"

copySampleFile () {
cp -i "$SRC_PATH/$1" $1
cp -i "$SRC_PATH/$1" "$1"
}

mkdir -p "www/nodejs-project"
Expand Down

0 comments on commit ff17e52

Please sign in to comment.