kakakakakku blog

Weekly Tech Blog: Keep on Learning!

本棚に眠っていた「一生モノの英語勉強法」を読み直した

いつ購入したのか正確には覚えていないけど,本棚に眠っていた「一生モノの英語勉強法」を読み直した📖

本書では「実践しやすい英語学習のコツ」が紹介されていて,自分自身にあった勉強法を見つけるのに使える一冊だった.関連書籍や学習リソースが多く紹介されているのも良かった.受験のために問題集をどう使うかというコツも載っていた.2013年に出版されているので,少し古くなっている書籍などは一部あるけど,それでも気になる書籍も見つかった.最近は英語学習の書籍をいくつか読んでいて,どの書籍にも似たようなことが載っているけど,本書は「理論と感覚」のバランスが良いと思った.

目次

  • 第1章 : 英語ができれば人生が変わる!
  • 第2章 : “武器”としての発音
  • 第3章 : 本当は「おもしろい」英文法
  • 第4章 : 英文を読む―「多読」と「精読」の訓練法
  • 第5章 : 単語力アップの秘訣―英語学習で最大の難関を突破するには
  • 第6章 : 聞く技術と話す技術
  • 第7章 : 英語学習を継続するために
  • 第8章 : 英語学習のための必須グッズ一〇選

読み直した感想

本書のサブタイトルに 「理系的」学習システムのすすめ と書いてある通り,英文法や読解を理論的に紹介しているところもあるけど,それでも「理屈と暗記のバランスが重要」と書かれていて納得感があった.当然ながら理系じゃなくても読めるし,そこは気にしなくて良いと思う.

また理系的な(科学的な)トピックを扱っていて英語学習にも使えるサイトとして Scientific AmericanScienceNature も紹介されていた.実際にサイトを見てみたけど,特に Scientific American「The 60-Second Podcast」は短くまとまってて,文字起こしもあってシャドーイングにも使えそうだった.シャドーイング候補に追加しておいた❗️

www.scientificamerican.com

www.science.org

www.nature.com

他にも参考になったコツがあった💡2022年8月頃から毎日欠かさずに「シャドーイング(ディクテーション・音読・オーバーラッピングも含む)」を続けているけど(詳しくはこちら!),最近は思ったほど上達を感じられなくなっていた.例えば以下など,今すぐ試せそうなコツに出会えたのは良かった❗️

  • 音読筆写をする(1文を音読したら瞬間的に覚えて書き出す訓練)
  • 目の前のネイティブスピーカーに読み聞かせているつもりで音読をする
  • 音読をするときは構造上おかしな箇所で区切らない
  • リード・アンド・ルックアップをする(1文を黙読したら瞬間的に覚えて音読をする訓練)

また単語(ボキャビル)に関しても伸びてる実感がなくモチベーションが下がっていて,どうしても正確的に完璧主義になってしまうけど,改めてマインドセットを見直す❗️

  • あまり欲張らない
  • 実際に出会った単語を覚える
  • 完璧を求めない

他には "基本単語1500語" で必要最低限のコミュニケーションを取る「Globish(グロービッシュ)」という英語術が紹介されていたのも興味を持った.

ja.wikipedia.org

気になった書籍

本書では多くの関連書籍が紹介されていて,実際に本棚に眠っているものもあって読み直そうと思った.他に気になった書籍も載せておく.順番に読んでいこう📖

act: GitHub Actions のワークフローをローカル環境で実行する

GitHub Actions でワークフローを実行するときに git commitgit push を実行して GitHub Actions の実行を待つことがよくある.より迅速に実行して,結果を受け取るために「act」を使って GitHub Actions をローカル環境(コンテナ)で実行する仕組みを試してみた.便利だったので紹介しようと思う❗️

当然ながら GitHub Actions を完全再現できてるわけではなく,最終的には GitHub Actions を使うことにはなるけど,特に開発中に頻繁にテストを実行できるのはメリットだと思う.うまく併用しながら開発体験を高めよう👌

github.com

セットアップ

macOS の場合は Homebrew を使って簡単にセットアップできる.他には Chocolatey (Windows)Bash script も選べる.今回は act 0.2.40Docker Desktop 4.16.1 を使う.

$ brew install act

$ act --version
act version 0.2.40

act コマンドには多くのオプションがある.以下に載せておく.

$ act --help
Run GitHub actions locally by specifying the event name (e.g. `push`) or an action name directly.

Usage:
  act [event name to run] [flags]

If no event name passed, will default to "on: push"
If actions handles only one event it will be used as default instead of "on: push"

Flags:
  -a, --actor string                                      user that triggered the event (default "nektos/act")
      --artifact-server-addr string                       Defines the address to which the artifact server binds. (default "10.0.0.6")
      --artifact-server-path string                       Defines the path where the artifact server stores uploads and retrieves downloads from. If not specified the artifact server will not start.
      --artifact-server-port string                       Defines the port where the artifact server listens. (default "34567")
  -b, --bind                                              bind working directory to container, rather than copy
      --bug-report                                        Display system information for bug report
      --container-architecture string                     Architecture which should be used to run containers, e.g.: linux/amd64. If not specified, will use host default architecture. Requires Docker server API Version 1.41+. Ignored on earlier Docker server platforms.
      --container-cap-add stringArray                     kernel capabilities to add to the workflow containers (e.g. --container-cap-add SYS_PTRACE)
      --container-cap-drop stringArray                    kernel capabilities to remove from the workflow containers (e.g. --container-cap-drop SYS_PTRACE)
      --container-daemon-socket string                    Path to Docker daemon socket which will be mounted to containers (default "/var/run/docker.sock")
      --container-options string                          Custom docker container options for the job container without an options property in the job definition
      --defaultbranch string                              the name of the main branch
      --detect-event                                      Use first event type from workflow as event that triggered the workflow
  -C, --directory string                                  working directory (default ".")
  -n, --dryrun                                            dryrun mode
      --env stringArray                                   env to make available to actions with optional value (e.g. --env myenv=foo or --env myenv)
      --env-file string                                   environment file to read and use as env in the containers (default ".env")
  -e, --eventpath string                                  path to event JSON file
      --github-instance string                            GitHub instance to use. Don't use this if you are not using GitHub Enterprise Server. (default "github.com")
  -g, --graph                                             draw workflows
  -h, --help                                              help for act
      --input stringArray                                 action input to make available to actions (e.g. --input myinput=foo)
      --input-file string                                 input file to read and use as action input (default ".input")
      --insecure-secrets                                  NOT RECOMMENDED! Doesn't hide secrets while printing logs.
  -j, --job string                                        run a specific job ID
      --json                                              Output logs in json format
  -l, --list                                              list workflows
      --no-recurse                                        Flag to disable running workflows from subdirectories of specified path in '--workflows'/'-W' flag
      --no-skip-checkout                                  Do not skip actions/checkout
  -P, --platform stringArray                              custom image to use per platform (e.g. -P ubuntu-18.04=nektos/act-environments-ubuntu:18.04)
      --privileged                                        use privileged mode
  -p, --pull                                              pull docker image(s) even if already present
  -q, --quiet                                             disable logging of output from steps
      --rebuild                                           rebuild local action docker image(s) even if already present
      --remote-name string                                git remote name that will be used to retrieve url of git repo (default "origin")
      --replace-ghe-action-token-with-github-com string   If you are using replace-ghe-action-with-github-com  and you want to use private actions on GitHub, you have to set personal access token
      --replace-ghe-action-with-github-com stringArray    If you are using GitHub Enterprise Server and allow specified actions from GitHub (github.com), you can set actions on this. (e.g. --replace-ghe-action-with-github-com =github/super-linter)
  -r, --reuse                                             don't remove container(s) on successfully completed workflow(s) to maintain state between runs
      --rm                                                automatically remove container(s)/volume(s) after a workflow(s) failure
  -s, --secret stringArray                                secret to make available to actions with optional value (e.g. -s mysecret=foo or -s mysecret)
      --secret-file string                                file with list of secrets to read from (e.g. --secret-file .secrets) (default ".secrets")
      --use-gitignore                                     Controls whether paths specified in .gitignore should be copied into container (default true)
      --userns string                                     user namespace to use
  -v, --verbose                                           verbose output
      --version                                           version for act
  -w, --watch                                             watch the contents of the local repo and run when files change
  -W, --workflows string                                  path to workflow file(s) (default "./.github/workflows/")

今回使うサンプルワークフロー

今回はサンプルとして,Python で実装した FizzBuzz コードに対して Flake8pytest を実行するワークフローを使う.GitHub Actions の「Starter Workflows」として公開されている python-package.yml をベースに .github/workflows/test.yaml を用意した.

name: Python package

on:
  push:
    - master
  pull_request:
    - master

jobs:
  build:

    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        python-version: ['3.8', '3.9', '3.10']

    steps:
    - uses: actions/checkout@v3
    - name: Set up Python ${{ matrix.python-version }}
      uses: actions/setup-python@v3
      with:
        python-version: ${{ matrix.python-version }}
    - name: Install dependencies
      run: |
        python -m pip install --upgrade pip
        python -m pip install flake8 pytest
        if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
    - name: Lint with flake8
      run: |
        flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
        flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
    - name: Test with pytest
      run: |
        pytest

github.com

act コマンドを試す

さっそく act コマンドを試していく❗️

act --list コマンド

act --list コマンドを実行するとワークフロー一覧を確認できる.

$ act --list
Stage  Job ID  Job name  Workflow name   Workflow file  Events
0      build   build     Python package  test.yaml      push,pull_request

act コマンド(初回実行)

act コマンドを実行するとワークフローを実行できる.初回実行の場合は実行時に使う Docker Image を Large / Medium / Micro から選ぶ.今回は Medium を選んだ.すると,自動的に ~/.actrc という設定ファイルが作られて,デフォルト設定として使えるようになる..actrc をリポジトリごとに作って設定を上書きすることもできる.

$ act
? Please choose the default image you want to use with act:

  - Large size image: +20GB Docker image, includes almost all tools used on GitHub Actions (IMPORTANT: currently only ubuntu-18.04 platform is available)
  - Medium size image: ~500MB, includes only necessary tools to bootstrap actions and aims to be compatible with all actions
  - Micro size image: <200MB, contains only NodeJS required to bootstrap actions, doesn't work with all actions

参考までに Large / Medium / Micro それぞれを選んだときに自動的に作られた ~/.actrc の設定ファイルを以下に載せておく.

Micro

-P ubuntu-latest=node:16-buster-slim
-P ubuntu-22.04=node:16-bullseye-slim
-P ubuntu-20.04=node:16-buster-slim
-P ubuntu-18.04=node:16-buster-slim

Medium

-P ubuntu-latest=catthehacker/ubuntu:act-latest
-P ubuntu-22.04=catthehacker/ubuntu:act-22.04
-P ubuntu-20.04=catthehacker/ubuntu:act-20.04
-P ubuntu-18.04=catthehacker/ubuntu:act-18.04

Large

-P ubuntu-latest=catthehacker/ubuntu:full-latest
-P ubuntu-latest=catthehacker/ubuntu:full-20.04
-P ubuntu-18.04=catthehacker/ubuntu:full-18.04

なお,act 0.2.40 までは Micro を選んだときに作られる設定ファイルが間違っていて,以下のプルリクエストを出して直しておいた.既にリリースされている act 0.2.41 で直っている✌️

github.com

今回のワークフローでは runs-on: ubuntu-latest と設定しているため,Medium だと catthehacker/ubuntu:act-latest イメージを使ってワークフローが実行される.現時点だと ubuntu-latestubuntu-22.04 を参照しているため,明示的に -P ubuntu-latest=catthehacker/ubuntu:act-22.04 と設定しておくのも良いかと〜

github.com

act コマンド

改めて act コマンドを実行するとワークフローを実行できる.今回は matrix を使って Python 3.8 / 3.9 / 3.10 を並列実行するため,実行ログには以下の3種類が混在する(見にくいため順番は入れ替えて載せている).また pip install の実行ログや pytest 実行ログも表示されるため,標準出力は非常に多くなってしまう💦

  • build-1: Python 3.8
  • build-2: Python 3.9
  • build-3: Python 3.10
$ act

(中略)

[Python package/build-1] 🧪  Matrix: map[python-version:3.8]
[Python package/build-2] 🧪  Matrix: map[python-version:3.9]
[Python package/build-3] 🧪  Matrix: map[python-version:3.10]
[Python package/build-1]   ✅  Success - Main actions/checkout@v3
[Python package/build-2]   ✅  Success - Main actions/checkout@v3
[Python package/build-3]   ✅  Success - Main actions/checkout@v3
[Python package/build-1]   ✅  Success - Main Set up Python 3.8
[Python package/build-2]   ✅  Success - Main Set up Python 3.9
[Python package/build-3]   ✅  Success - Main Set up Python 3.10
[Python package/build-1]   ✅  Success - Main Install dependencies
[Python package/build-2]   ✅  Success - Main Install dependencies
[Python package/build-3]   ✅  Success - Main Install dependencies
[Python package/build-1]   ✅  Success - Main Lint with flake8
[Python package/build-2]   ✅  Success - Main Lint with flake8
[Python package/build-3]   ✅  Success - Main Lint with flake8
[Python package/build-1]   ✅  Success - Main Test with pytest
[Python package/build-2]   ✅  Success - Main Test with pytest
[Python package/build-3]   ✅  Success - Main Test with pytest
[Python package/build-1]   ✅  Success - Post Set up Python 3.8
[Python package/build-2]   ✅  Success - Post Set up Python 3.9
[Python package/build-3]   ✅  Success - Post Set up Python 3.10
[Python package/build-1] 🏁  Job succeeded
[Python package/build-2] 🏁  Job succeeded
[Python package/build-3] 🏁  Job succeeded

act --quiet コマンド

標準出力を "多少" 減らすときは --quiet オプションを組み合わせて使う.pip install の実行ログや pytest 実行ログを非表示にできる.それでもまだ多いけど〜

$ act --quiet

(中略)

[Python package/build-1] 🧪  Matrix: map[python-version:3.8]
[Python package/build-2] 🧪  Matrix: map[python-version:3.9]
[Python package/build-3] 🧪  Matrix: map[python-version:3.10]
[Python package/build-1]   ✅  Success - Main actions/checkout@v3
[Python package/build-2]   ✅  Success - Main actions/checkout@v3
[Python package/build-3]   ✅  Success - Main actions/checkout@v3
[Python package/build-1]   ✅  Success - Main Set up Python 3.8
[Python package/build-2]   ✅  Success - Main Set up Python 3.9
[Python package/build-3]   ✅  Success - Main Set up Python 3.10
[Python package/build-1]   ✅  Success - Main Install dependencies
[Python package/build-2]   ✅  Success - Main Install dependencies
[Python package/build-3]   ✅  Success - Main Install dependencies
[Python package/build-1]   ✅  Success - Main Lint with flake8
[Python package/build-2]   ✅  Success - Main Lint with flake8
[Python package/build-3]   ✅  Success - Main Lint with flake8
[Python package/build-1]   ✅  Success - Main Test with pytest
[Python package/build-2]   ✅  Success - Main Test with pytest
[Python package/build-3]   ✅  Success - Main Test with pytest
[Python package/build-1]   ✅  Success - Post Set up Python 3.8
[Python package/build-2]   ✅  Success - Post Set up Python 3.9
[Python package/build-3]   ✅  Success - Post Set up Python 3.10
[Python package/build-1] 🏁  Job succeeded
[Python package/build-2] 🏁  Job succeeded
[Python package/build-3] 🏁  Job succeeded

act --reuse コマンド

ワークフロー実行時に構築するイメージを再利用する場合は --reuse オプションを組み合わせて使う.実行時間は多少早くなる.

$ act --reuse

act --watch コマンド

--watch オプションを使うとコードやワークフロー設定の変更を検知して,自動的にワークフローを再実行できる.ただし,実際に試してみると,1度テストが落ちると再実行されず,挙動に不安があった🌀

$ act --watch

(中略)

[Python package/build-1]   ❌  Failure - Main Test with pytest
[Python package/build-2]   ❌  Failure - Main Test with pytest
[Python package/build-3]   ❌  Failure - Main Test with pytest

act --env-fileact --secret-file コマンド

ワークフローに「環境変数」「シークレット」を設定する場合,以下のように --env-file--secret-file オプションを使ってファイルを読み込める.直接設定するなら --env--secret オプションも使えるけど,特にシークレットはファイルを読み込むのが良さそう.

$ act --env-file my.env
$ act --secret-file my.secrets

act pull_requestact schedule コマンド

実は act コマンドを実行すると GitHub に対する push イベントをトリガーするワークフローを実行している.例えば,プルリクエスト時に一部異なるワークフローを実行しているような場合は act pull_request コマンドを実行すると pull_request イベントをトリガーするワークフローを実行できる.スケジュール実行をしているような場合は act schedule コマンドを実行すると schedule イベントをトリガーするワークフローを実行できる.

on:
  push:
    branches:
      - master
    pull_request:
      - master

もしワークフローの中で github.event.pull_request.* などのイベントプロパティに依存している場合は --eventpath オプションを組み合わせる.詳しくは Wiki の Beginner's guide に載っている.

github.com

まとめ

GitHub Actions のワークフローをローカル環境で実行できる「act」を試した❗️

調べたところ「act」は GitHub Blog でも紹介されていた.

github.blog

実際に試してみて act は便利だったけど,当然ながら GitHub Actions を完全再現できてるわけではなく,例えば「実行できる環境が Ubuntu 限定」や,前に紹介した GitHub Actions の「reusable workflow(ワークフローの再利用)未対応」などは気にしておく必要があると思う.あとワークフローがエラーになって再試行で直るなど不安定な挙動もあって,もう少し使ってみようと思う🌀

$ act
Error: remote reusable workflows are currently not supported (see https://github.com/nektos/act/issues/826 for updates)

kakakakakku.hatenablog.com

Calendly: Zapier を使って Notion と連携しよう

「Calendly」は多くのサービスとのインテグレーションをサポートしている."Professional" プラン以上で使える「Zapier インテグレーション」で連携すると,開発をすることなく(ノーコード)イベント駆動な仕組みを実装できる.

Calendly を試しながら「ミーティングの申し込みがあったら自動的に Notion にドキュメントを作る」ということを実現したく,トライアル期間中に Zapier との連携を実装してみた❗️実際に使っていて便利〜(課金したくなる...💰)プラン詳細は以下のドキュメントにまとまっている!

calendly.com

Calendly に関しては以下の記事で紹介しているので読んでもらえればと〜📝

kakakakakku.hatenablog.com

Zapier セットアップ

最初に Calendly 側で Zapier 用の API Key を取得して,Zapier の Zap に設定する.

次に Zapier 側で Trigger (Calendly)Action (Notion) を設定する.Notion ドキュメントのタイトルと本文には Calendly のフィールド値を設定する.候補日だけではなく質問に対する回答なども取得できる.

すると自動的に Notion ドキュメントが作られる❗️

Calendly: 気軽に 1on1 を申し込もう

仕事に関係なく「話したいなぁ〜」と思った相手とのミーティング(1on1 / 壁打ち / 技術雑談など)を気軽に申し込めるサービス「Calendly」を紹介する❗️ちょっと前から気になってて,試してみたら便利でさっそく導入(テスト運用中)もしてみた.機能は限られるけど,無料で使える "Basic" でも問題なさそう〜

calendly.com

Calendly 操作イメージ🎤

Calendly を使って「ミーティングを申し込む流れ」を見てもらえばイメージは掴めると思う❗️

1. Calendly サイトにアクセスする

Calendly サイトにアクセスすると,設定しているイベント「1on1」を選べる.本当は「Blog 1on1」「Tech 1on1」「General 1on1」など複数イベントを設定したかったけど,Basic プランだと1イベントのみ設定できるようになっている.

2. 候補日を選ぶ

次に候補日を選ぶ!日時と時間は管理画面で細かく設定していて,以下の例だと 1/3110:0010:30 で申し込める.

3. 質問に回答する

名前や 1on1 トピックなど,簡単な質問に回答して申し込み完了!今回は Google Meet を使う設定にしている.当日お会いしましょう!簡単便利〜 (・∀・)

Calendly 機能紹介🎤

インテグレーションの多さ

Calendly は多くのサービスとのインテグレーションをサポートしている.「カレンダーサービス」なら Google Calendar や Office 365 Calendar などをサポートしていて,「ビデオ会議サービス」なら Zoom や Google Meet や Microsoft Teams などをサポートしている.インテグレーションは他にもまだまだある❗️

柔軟な質問を設定できる

ミーティングを申し込む前に質問に回答してもらえる.多すぎると面倒だけど,アジェンダなど最低限の情報を把握できるのはお互いに助かると思う.回答タイプも充実していて便利❗️

  • One Line(一行テキスト)
  • Multiple Lines(複数行テキスト)
  • Radio Buttons(単一選択)
  • Checkboxes(複数選択)
  • Dropdown(単一選択)
  • Phone Number(電話番号)

ミーティングが隙間なく埋まらないようにブロックできる

Before eventAfter event を設定することで,ミーティングが隙間なく埋まらないようにミーティングの前後をブロックできる.準備時間や休憩時間を確保できてイイ❗️

他の予定とコンフリクトしないように考慮できる

Calendly で「毎週何時」「特定日」など,候補日を柔軟に設定できるけど,気になるのは他の予定が入ったときに Calendly への反映を忘れてしまって「ダブルブッキングになってしまった💦」という事故だと思う.Calendly には「Check for conflicts」という機能があって,例えば Google Calendar だと指定したカレンダーに予定が入っていたら(コンフリクトしそうだったら)候補日にならないようにしてくれる.これは本当に便利な機能で Calendly の管理がしやすくなる❗️

サイトに埋め込める

Calendly をサイトに埋め込む機能もある.現時点では3種類ある.個人的には「ポップアップボタン」があると良いなぁ〜と思った.今後に期待❗️

  • Inline Embed(Calendly を直接埋め込む)
  • Popup Widget(フローティングしたボタンをクリックすると Calendly が表示される)
  • Popup Text(テキストリンクをクリックすると Calendly が表示される)

まとめ

「Calendly」を試してみた❗️個人利用でも企業利用でも便利だと思う〜

今年はテックブログに関する壁打ちや雑談などをもっと気軽にできたら良いなぁ〜と思っていて,さっそく Calendly を導入してみた.現状まだ「テスト運用中」で候補日は少ないけど,kakakakakku blog のサイドバーに Popup Text を埋め込んでおいた.もしくは以下のリンクから直接アクセスしてもらっても OK💡実際に運用をしてみないとわからないこともあってお話しましょう〜

calendly.com

GitHub App「Pull Request Size」プルリクエストのサイズをラベル化しよう

GitHub App「Pull Request Size」を使うとプルリクエストの差分量から "サイズを意味する" ラベルを付けてくれて便利❗️やってることは単純だけど「このプルリクエストは大きすぎるな〜」という判断材料にも使える.個人アカウントなら無料なのも嬉しい✌️

github.com

ラベル一覧

ラベルに関しては以下の「計6種類」が用意されている!

  • size/XS : 差分量 0-9 行
  • size/S : 差分量 10-29 行
  • size/M : 差分量 30-99 行
  • size/L : 差分量 100-499 行
  • size/XL : 差分量 500-999 行
  • size/XXL : 差分量 1000 行 以上

差分量の計算式と除外ファイル

「差分量」を算出する計算式は GitHub に載っていて,基本的には「追加 + 削除」になる.でも generated file(自動生成されるファイル) の差分を除外してくれるのはよく考えられていると思った❗️具体的には node_modules/ ディレクトリなどが考慮されていて,一覧は GitHub の noqcks/generated リポジトリで管理されている.さらに「Pull Request Size」では .gitattributes を使うと除外ファイルをカスタマイズすることもできる〜

total additions + total deletions - (all generated file additions/deletions)

github.com

github.com

ラベルの色をカスタマイズする

カスタマイズという観点だと .github/labels.yml ファイルを使って「ラベルの色」も設定できる.痒いところに手が届く感じ❗️

XS:
  name: size/XS
  lines: 0
  color: 3CBF00
S:
  name: size/S
  lines: 10
  color: 5D9801

プルリクエストを更新するとラベルは更新される

プルリクエストを出した後にレビューを繰り返しながらコードを修正したらどうなるんだろうと気になった.実際に試したところ,コミットごとに計算されて自動的にラベルは更新された❗️

まとめ

さっそく GitHub App「Pull Request Size」を使っていくぞー❗️

ツイート