rolling #528
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
permissions: | |
contents: read | |
on: | |
push: | |
branches: [main] | |
pull_request: | |
schedule: | |
- cron: '0 18 * * *' | |
name: rolling | |
jobs: | |
# https://twitter.com/mycoliza/status/1571295690063753218 | |
# https://github.com/rust-lang/rust/issues/107678 | |
nightly: | |
runs-on: ubuntu-latest | |
name: ubuntu / nightly | |
env: | |
DB_DATABASE: ccgbot_rust | |
DB_USER: root | |
DB_PASS: root | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- name: Install nightly | |
uses: dtolnay/rust-toolchain@nightly | |
- name: cargo generate-lockfile | |
if: hashFiles('Cargo.lock') == '' | |
run: cargo generate-lockfile | |
- name: Setup MySql | |
# start service and create user | |
run: | | |
sudo /etc/init.d/mysql start | |
mysql -e "CREATE USER 'ccgbotrust'@'localhost' IDENTIFIED WITH 'caching_sha2_password' REQUIRE NONE PASSWORD EXPIRE NEVER ACCOUNT UNLOCK PASSWORD HISTORY DEFAULT PASSWORD REUSE INTERVAL DEFAULT PASSWORD REQUIRE CURRENT DEFAULT; FLUSH PRIVILEGES; UNLOCK TABLES;" -u$DB_USER -p$DB_PASS | |
mysql -e "GRANT ALL ON $DB_DATABASE.* TO 'ccgbotrust'@'localhost'; FLUSH PRIVILEGES;" -u$DB_USER -p$DB_PASS | |
- name: Create Database | |
run: mysql -e "CREATE DATABASE IF NOT EXISTS $DB_DATABASE;" -u$DB_USER -p$DB_PASS | |
- name: Create tables | |
run: | | |
mysql -e 'CREATE TABLE `twitchuser` (`tid` int unsigned NOT NULL, `username` varchar(25) NOT NULL, PRIMARY KEY (`tid`)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci' -u$DB_USER -p$DB_PASS $DB_DATABASE | |
mysql -e 'CREATE TABLE `discorduser` (`did` bigint unsigned NOT NULL,`username` varchar(25) NOT NULL,PRIMARY KEY (`did`)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci' -u$DB_USER -p$DB_PASS $DB_DATABASE | |
mysql -e 'CREATE TABLE `users` (`id` int unsigned NOT NULL, `uid` int unsigned NOT NULL, `discord_id` bigint unsigned NOT NULL, `twitch_id` int unsigned NOT NULL, PRIMARY KEY (`id`), KEY `discord_id` (`discord_id`), KEY `twitch_id` (`twitch_id`), CONSTRAINT `users_ibfk_1` FOREIGN KEY (`discord_id`) REFERENCES `discorduser` (`did`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `users_ibfk_2` FOREIGN KEY (`twitch_id`) REFERENCES `twitchuser` (`tid`) ON DELETE CASCADE ON UPDATE CASCADE) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci' -u$DB_USER -p$DB_PASS $DB_DATABASE | |
- name: Insert into Database | |
run: | | |
mysql -e 'INSERT INTO `twitchuser` VALUES (12345678, "testuser");' -u$DB_USER -p$DB_PASS $DB_DATABASE | |
mysql -e 'INSERT INTO `discorduser` VALUES (123456789012345, "testuser");' -u$DB_USER -p$DB_PASS $DB_DATABASE | |
mysql -e 'INSERT INTO `users` VALUES (1, 1, 123456789012345, 12345678)' -u$DB_USER -p$DB_PASS $DB_DATABASE | |
- name: cargo test --locked | |
run: cargo test --locked --all-features --all-targets | |
# https://twitter.com/alcuadrado/status/1571291687837732873 | |
update: | |
runs-on: ubuntu-latest | |
name: ubuntu / beta / updated | |
# There's no point running this if no Cargo.lock was checked in in the | |
# first place, since we'd just redo what happened in the regular test job. | |
# Unfortunately, hashFiles only works in if on steps, so we repeat it. | |
# if: hashFiles('Cargo.lock') != '' | |
env: | |
DB_DATABASE: ccgbot_rust | |
DB_USER: root | |
DB_PASS: root | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- name: Install beta | |
if: hashFiles('Cargo.lock') != '' | |
uses: dtolnay/rust-toolchain@beta | |
- name: cargo update | |
if: hashFiles('Cargo.lock') != '' | |
run: cargo update | |
- name: Setup MySql | |
# start service and create user | |
run: | | |
sudo /etc/init.d/mysql start | |
mysql -e "CREATE USER 'ccgbotrust'@'localhost' IDENTIFIED WITH 'caching_sha2_password' REQUIRE NONE PASSWORD EXPIRE NEVER ACCOUNT UNLOCK PASSWORD HISTORY DEFAULT PASSWORD REUSE INTERVAL DEFAULT PASSWORD REQUIRE CURRENT DEFAULT; FLUSH PRIVILEGES; UNLOCK TABLES;" -u$DB_USER -p$DB_PASS | |
mysql -e "GRANT ALL ON $DB_DATABASE.* TO 'ccgbotrust'@'localhost'; FLUSH PRIVILEGES;" -u$DB_USER -p$DB_PASS | |
- name: Create Database | |
run: mysql -e "CREATE DATABASE IF NOT EXISTS $DB_DATABASE;" -u$DB_USER -p$DB_PASS | |
- name: Create tables | |
run: | | |
mysql -e 'CREATE TABLE `twitchuser` (`tid` int unsigned NOT NULL, `username` varchar(25) NOT NULL, PRIMARY KEY (`tid`)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci' -u$DB_USER -p$DB_PASS $DB_DATABASE | |
mysql -e 'CREATE TABLE `discorduser` (`did` bigint unsigned NOT NULL,`username` varchar(25) NOT NULL,PRIMARY KEY (`did`)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci' -u$DB_USER -p$DB_PASS $DB_DATABASE | |
mysql -e 'CREATE TABLE `users` (`id` int unsigned NOT NULL, `uid` int unsigned NOT NULL, `discord_id` bigint unsigned NOT NULL, `twitch_id` int unsigned NOT NULL, PRIMARY KEY (`id`), KEY `discord_id` (`discord_id`), KEY `twitch_id` (`twitch_id`), CONSTRAINT `users_ibfk_1` FOREIGN KEY (`discord_id`) REFERENCES `discorduser` (`did`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `users_ibfk_2` FOREIGN KEY (`twitch_id`) REFERENCES `twitchuser` (`tid`) ON DELETE CASCADE ON UPDATE CASCADE) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci' -u$DB_USER -p$DB_PASS $DB_DATABASE | |
- name: Insert into Database | |
run: | | |
mysql -e 'INSERT INTO `twitchuser` VALUES (12345678, "testuser");' -u$DB_USER -p$DB_PASS $DB_DATABASE | |
mysql -e 'INSERT INTO `discorduser` VALUES (123456789012345, "testuser");' -u$DB_USER -p$DB_PASS $DB_DATABASE | |
mysql -e 'INSERT INTO `users` VALUES (1, 1, 123456789012345, 12345678)' -u$DB_USER -p$DB_PASS $DB_DATABASE | |
- name: cargo test | |
if: hashFiles('Cargo.lock') != '' | |
run: cargo test --locked --all-features --all-targets | |
env: | |
RUSTFLAGS: -D deprecated | |
audit: | |
runs-on: ubuntu-latest | |
name: ubuntu / audit | |
# There's no point running this if no Cargo.lock was checked in in the | |
# first place, since we'd just redo what happened in the regular test job. | |
# Unfortunately, hashFiles only works in if on steps, so we repeat it. | |
# if: hashFiles('Cargo.lock') != '' | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- name: Install stable | |
if: hashFiles('Cargo.lock') != '' | |
uses: dtolnay/rust-toolchain@stable | |
- name: cargo audit | |
uses: actions-rs/audit-check@v1 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} |